From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 6/7] Avoid -Wnarrowing warnings in gdbserver
Date: Wed, 08 Aug 2018 23:20:00 -0000 [thread overview]
Message-ID: <20180808232016.12777-7-tom@tromey.com> (raw)
In-Reply-To: <20180808232016.12777-1-tom@tromey.com>
This avoids -Wnarrowing warnings in gdbserver, by introducing some
casts to unsigned char.
gdb/gdbserver/ChangeLog
2018-08-08 Tom Tromey <tom@tromey.com>
* linux-s390-low.c (s390_emit_ext, s390_emit_litpool)
(s390_emit_const, s390_emit_reg, s390_emit_zero_ext)
(s390_emit_stack_adjust, s390_emit_set_r2, s390x_emit_ext)
(s390x_emit_const, s390x_emit_reg, s390x_emit_zero_ext)
(s390x_emit_stack_adjust): Add casts to unsigned char.
---
gdb/gdbserver/ChangeLog | 8 ++++++
gdb/gdbserver/linux-s390-low.c | 56 ++++++++++++++++++++++++++++--------------
2 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c
index fff839bdd7..042a0f82d9 100644
--- a/gdb/gdbserver/linux-s390-low.c
+++ b/gdb/gdbserver/linux-s390-low.c
@@ -1605,8 +1605,8 @@ static void
s390_emit_ext (int arg)
{
unsigned char buf[] = {
- 0x8d, 0x20, 0x00, 64 - arg, /* sldl %r2, <64-arg> */
- 0x8e, 0x20, 0x00, 64 - arg, /* srda %r2, <64-arg> */
+ 0x8d, 0x20, 0x00, (unsigned char) (64 - arg), /* sldl %r2, <64-arg> */
+ 0x8e, 0x20, 0x00, (unsigned char) (64 - arg), /* srda %r2, <64-arg> */
};
add_insns (buf, sizeof buf);
}
@@ -1837,7 +1837,8 @@ s390_emit_litpool (int size)
0x07, 0x07,
};
unsigned char buf[] = {
- 0xa7, 0x15, 0x00, (size + 4) / 2, /* bras %r1, .Lend+size */
+ 0xa7, 0x15, 0x00,
+ (unsigned char) ((size + 4) / 2), /* bras %r1, .Lend+size */
/* .Lend: */
};
if (size == 4)
@@ -1861,8 +1862,11 @@ s390_emit_const (LONGEST num)
{
unsigned long long n = num;
unsigned char buf_s[] = {
- 0xa7, 0x38, num >> 8, num, /* lhi %r3, <num> */
- 0x17, 0x22, /* xr %r2, %r2 */
+ /* lhi %r3, <num> */
+ 0xa7, 0x38,
+ (unsigned char) (num >> 8), (unsigned char) num,
+ /* xr %r2, %r2 */
+ 0x17, 0x22,
};
static const unsigned char buf_l[] = {
0x98, 0x23, 0x10, 0x00, /* lm %r2, %r3, 0(%r1) */
@@ -1902,8 +1906,10 @@ static void
s390_emit_reg (int reg)
{
unsigned char bufpre[] = {
- 0x18, 0x29, /* lr %r2, %r9 */
- 0xa7, 0x38, reg >> 8, reg, /* lhi %r3, <reg> */
+ /* lr %r2, %r9 */
+ 0x18, 0x29,
+ /* lhi %r3, <reg> */
+ 0xa7, 0x38, (unsigned char) (reg >> 8), (unsigned char) reg,
};
add_insns (bufpre, sizeof bufpre);
s390_emit_call (get_raw_reg_func_addr ());
@@ -1939,8 +1945,8 @@ static void
s390_emit_zero_ext (int arg)
{
unsigned char buf[] = {
- 0x8d, 0x20, 0x00, 64 - arg, /* sldl %r2, <64-arg> */
- 0x8c, 0x20, 0x00, 64 - arg, /* srdl %r2, <64-arg> */
+ 0x8d, 0x20, 0x00, (unsigned char) (64 - arg), /* sldl %r2, <64-arg> */
+ 0x8c, 0x20, 0x00, (unsigned char) (64 - arg), /* srdl %r2, <64-arg> */
};
add_insns (buf, sizeof buf);
}
@@ -1965,7 +1971,9 @@ static void
s390_emit_stack_adjust (int n)
{
unsigned char buf[] = {
- 0xa7, 0xfa, n * 8 >> 8, n * 8, /* ahi %r15, 8*n */
+ /* ahi %r15, 8*n */
+ 0xa7, 0xfa,
+ (unsigned char ) (n * 8 >> 8), (unsigned char) (n * 8),
};
add_insns (buf, sizeof buf);
}
@@ -1976,7 +1984,8 @@ static void
s390_emit_set_r2 (int arg1)
{
unsigned char buf_s[] = {
- 0xa7, 0x28, arg1 >> 8, arg1, /* lhi %r2, <arg1> */
+ /* lhi %r2, <arg1> */
+ 0xa7, 0x28, (unsigned char) (arg1 >> 8), (unsigned char) arg1,
};
static const unsigned char buf_l[] = {
0x58, 0x20, 0x10, 0x00, /* l %r2, 0(%r1) */
@@ -2330,8 +2339,10 @@ static void
s390x_emit_ext (int arg)
{
unsigned char buf[] = {
- 0xeb, 0x22, 0x00, 64 - arg, 0x00, 0x0d, /* sllg %r2, %r2, <64-arg> */
- 0xeb, 0x22, 0x00, 64 - arg, 0x00, 0x0a, /* srag %r2, %r2, <64-arg> */
+ /* sllg %r2, %r2, <64-arg> */
+ 0xeb, 0x22, 0x00, (unsigned char) (64 - arg), 0x00, 0x0d,
+ /* srag %r2, %r2, <64-arg> */
+ 0xeb, 0x22, 0x00, (unsigned char) (64 - arg), 0x00, 0x0a,
};
add_insns (buf, sizeof buf);
}
@@ -2499,7 +2510,8 @@ s390x_emit_const (LONGEST num)
{
unsigned long long n = num;
unsigned char buf_s[] = {
- 0xa7, 0x29, num >> 8, num, /* lghi %r2, <num> */
+ /* lghi %r2, <num> */
+ 0xa7, 0x29, (unsigned char) (num >> 8), (unsigned char) num,
};
static const unsigned char buf_l[] = {
0xe3, 0x20, 0x10, 0x00, 0x00, 0x04, /* lg %r2, 0(%r1) */
@@ -2539,8 +2551,10 @@ static void
s390x_emit_reg (int reg)
{
unsigned char buf[] = {
- 0xb9, 0x04, 0x00, 0x29, /* lgr %r2, %r9 */
- 0xa7, 0x39, reg >> 8, reg, /* lghi %r3, <reg> */
+ /* lgr %r2, %r9 */
+ 0xb9, 0x04, 0x00, 0x29,
+ /* lghi %r3, <reg> */
+ 0xa7, 0x39, (unsigned char) (reg >> 8), (unsigned char) reg,
};
add_insns (buf, sizeof buf);
s390x_emit_call (get_raw_reg_func_addr ());
@@ -2576,8 +2590,10 @@ static void
s390x_emit_zero_ext (int arg)
{
unsigned char buf[] = {
- 0xeb, 0x22, 0x00, 64 - arg, 0x00, 0x0d, /* sllg %r2, %r2, <64-arg> */
- 0xeb, 0x22, 0x00, 64 - arg, 0x00, 0x0c, /* srlg %r2, %r2, <64-arg> */
+ /* sllg %r2, %r2, <64-arg> */
+ 0xeb, 0x22, 0x00, (unsigned char) (64 - arg), 0x00, 0x0d,
+ /* srlg %r2, %r2, <64-arg> */
+ 0xeb, 0x22, 0x00, (unsigned char) (64 - arg), 0x00, 0x0c,
};
add_insns (buf, sizeof buf);
}
@@ -2601,7 +2617,9 @@ static void
s390x_emit_stack_adjust (int n)
{
unsigned char buf[] = {
- 0xa7, 0xfb, n * 8 >> 8, n * 8, /* aghi %r15, 8*n */
+ /* aghi %r15, 8*n */
+ 0xa7, 0xfb,
+ (unsigned char) (n * 8 >> 8), (unsigned char) (n * 8),
};
add_insns (buf, sizeof buf);
}
--
2.13.6
next prev parent reply other threads:[~2018-08-08 23:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-08 23:20 [PATCH 0/7] Remove -Wno-narrowing Tom Tromey
2018-08-08 23:20 ` Tom Tromey [this message]
2018-08-08 23:20 ` [PATCH 5/7] Avoid -Wnarrowing warnings in ppc64-tdep.c Tom Tromey
2018-08-08 23:20 ` [PATCH 2/7] Use CORE_ADDR_MAX in various "breaks" arrays Tom Tromey
2018-08-09 18:08 ` Pedro Alves
2018-08-08 23:20 ` [PATCH 4/7] Fix two -Wnarrowing warnings in xtensa-tdep.h Tom Tromey
2018-08-09 18:09 ` Pedro Alves
2018-08-08 23:20 ` [PATCH 7/7] Remove -Wno-narrowing from warnings.m4 Tom Tromey
2018-08-09 18:10 ` Pedro Alves
2018-08-27 17:46 ` Tom Tromey
2018-08-27 18:00 ` Tom Tromey
2018-08-08 23:20 ` [PATCH 1/7] Change completion_tracker to use char type Tom Tromey
2018-08-09 17:38 ` Pedro Alves
2018-08-09 18:42 ` Tom Tromey
2018-08-09 18:50 ` Pedro Alves
2018-08-08 23:20 ` [PATCH 3/7] Avoid -Wnarrowing warnings in struct tramp_frame instances Tom Tromey
2018-08-09 18:08 ` Pedro Alves
2018-08-09 18:17 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180808232016.12777-7-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox