[Toybox] i18n configuration in toy_singleinit

enh enh at google.com
Thu Mar 26 12:59:15 PDT 2015


On Thu, Mar 26, 2015 at 12:30 PM, Rob Landley <rob at landley.net> wrote:
> On Wed, Mar 25, 2015 at 12:51 PM, Jim Huang <jserv at 0xlab.org> wrote:
>> main.c:72:45: warning: adding 'int' to a string does not append to the
>> string [-Wstring-plus-int]
>
> I just noticed the -Wstring-plus-int above. does this fix it?

yes. clang always tells you how to disable the warning if it's possible.

as for the usefulness of this particular warning, we have seen it
catch real bugs in OEM code :-(

if you're interested, here's what clang doesn't like in Android's
current subset of toybox:

external/toybox/toys/lsb/md5sum.c:237:54: warning: data argument not
used by format string [-Wformat-extra-args]
  printf((toys.optflags & FLAG_b) ? "\n" : "  %s\n", name);
                                    ~~~~             ^

external/toybox/toys/pending/expr.c:260:29: warning: missing field 'i'
initializer [-Wmissing-field-initializers]
  struct value tok, ret = {0};
                            ^

external/toybox/toys/pending/netstat.c:194:26: warning: use of logical
'&&' with constant operand [-Wconstant-logical-operand]
    if (!rport && (state && 0xA)) display_data(rport, label, rxq, txq,
lip, rip, state, inode);
                         ^  ~~~

the first of these is one of those things that's _usually_ a bug but
isn't here. the second seems to be a bug in clang to me. the last
seems like a bug in netstat.

diff --git a/toys/pending/netstat.c b/toys/pending/netstat.c
index fbb9eb1..11f4fb0 100644
--- a/toys/pending/netstat.c
+++ b/toys/pending/netstat.c
@@ -191,10 +191,10 @@ static void display_data(unsigned rport, char
*label, unsigned rxq, unsigned txq
 static void show_data(unsigned rport, char *label, unsigned rxq,
unsigned txq, char *lip, char *rip, unsigned state, unsigned long
inode)
 {
   if (toys.optflags & FLAG_l) {
-    if (!rport && (state && 0xA)) display_data(rport, label, rxq,
txq, lip, rip, state, inode);
+    if (!rport && (state & 0xA)) display_data(rport, label, rxq, txq,
lip, rip, state, inode);
   } else if (toys.optflags & FLAG_a) display_data(rport, label, rxq,
txq, lip, rip, state, inode);
-  //rport && (TCP | UDP | RAW)
-  else if (rport && (0x10 | 0x20 | 0x40)) display_data(rport, label,
rxq, txq, lip, rip, state, inode);
+  //rport & (TCP | UDP | RAW)
+  else if (rport & (0x10 | 0x20 | 0x40)) display_data(rport, label,
rxq, txq, lip, rip, state, inode);
 }
 /*
  * used to get service name.

(yeah, i know, "don't use pending"... :-) )

> diff -r dbee4e656aa6 configure
> --- a/configure Thu Mar 26 13:25:20 2015 -0500
> +++ b/configure Thu Mar 26 14:27:43 2015 -0500
> @@ -7,7 +7,7 @@
>
>  # CFLAGS and OPTIMIZE are different so you can add extra CFLAGS without
>  # disabling default optimizations
> -[ -z "$CFLAGS" ] && CFLAGS="-Wall -Wundef -Wno-char-subscripts"
> +[ -z "$CFLAGS" ] && CFLAGS="-Wall -Wundef -Wno-char-subscripts
> -Wno-string-plus-int"
>  # Required for our expected ABI. we're 8-bit clean thus "char" must
> be unsigned.
>  CFLAGS="$CFLAGS -funsigned-char"
>  [ -z "$OPTIMIZE" ] && OPTIMIZE="-Os -ffunction-sections
> -fdata-sections -fno-asynchronous-unwind-tables"
>
> (Sorry if gmail mangles the above, I'm on the road and have to use the
> web interface. Hopefully the intent is clear: add -Wno-string-plus-int
> to CFLAGS. It doesn't seem to bother gcc...)
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

 1427399955.0


More information about the Toybox mailing list