[Toybox] [PATCH] New command: flock

enh enh at google.com
Tue Oct 6 15:12:22 PDT 2015


On Tue, Oct 6, 2015 at 5:26 AM, Rob Landley <rob at landley.net> wrote:
> On 09/10/2015 08:32 PM, enh wrote:
>> New command: flock.
>>
>> The brillo folks wanted this in a shell script they're porting over
>> (so I've only implemented the fd style they wanted, not the named file
>> style).
>
> Applied to toys/other.

thanks. merged into AOSP.

> Does llvm complain about if (variable & constant) the way it complains
> about = instead of ==? (I.E. are those double parentheses actually
> needed to suppress a warning? It seems like if the & is against a
> constant, the compiler has no business warning about it...)

no, it doesn't. that was me attempting to follow your style and
falling half-way between our ((a & B) != 0) and your (a & B). (a
clang-format config would help.)

attached is a patch for something related that clang does warn about
(use of logical '&&' with constant operand).

-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
-------------- next part --------------
diff --git a/toys/pending/netstat.c b/toys/pending/netstat.c
index 735f1b1..3ee4c5a 100644
--- a/toys/pending/netstat.c
+++ b/toys/pending/netstat.c
@@ -161,10 +161,10 @@ static void show_data(unsigned rport, char *label, unsigned rxq, unsigned txq,
                       unsigned long inode)
 {
   if (toys.optflags & FLAG_l) {
-    if (!rport && (state && 0xA)) display_data(rport, label, rxq, txq, lip, rip, state, uid, inode);
+    if (!rport && (state & 0xA)) display_data(rport, label, rxq, txq, lip, rip, state, uid, inode);
   } else if (toys.optflags & FLAG_a) display_data(rport, label, rxq, txq, lip, rip, state, uid, inode);
   //rport && (TCP | UDP | RAW)
-  else if (rport && (0x10 | 0x20 | 0x40)) display_data(rport, label, rxq, txq, lip, rip, state, uid, inode);
+  else if (rport & (0x10 | 0x20 | 0x40)) display_data(rport, label, rxq, txq, lip, rip, state, uid, inode);
 }
 /*
  * used to get service name.


More information about the Toybox mailing list