summary refs log tree commit diff
diff options
context:
space:
mode:
authorZ. Liu <zhixu.liu@gmail.com>2024-08-25 00:47:38 +0800
committerGerrit Pape <pape@smarden.org>2024-09-26 00:00:00 +0000
commit30ffd04a9415713006c45fdc3e7978b8bfae0352 (patch)
tree13ec018392ee6341517060794d4db3ec51edd3d1
parent9b4bd605e77827ce2ab1dd39f1552072d639f7e6 (diff)
downloadrunit-30ffd04a9415713006c45fdc3e7978b8bfae0352.tar.gz
runit-30ffd04a9415713006c45fdc3e7978b8bfae0352.tar.xz
runit-30ffd04a9415713006c45fdc3e7978b8bfae0352.zip
fix compilation warning(s): -Wunsequenced
found by using clang 18 with CFLAGS: -Wall

link of debian's patches is: https://salsa.debian.org/debian/runit/-/tree/master/debian/patches
  0016-fix-warning-for-undefined-operation-on-sequence-poin.patch

chpst.c:312:33: warning: unsequenced modification and access to 'subgetoptarg' [-Wunsequenced]
  312 |           if (optarg[scan_ulong(++optarg, &ul)]) usage(); nicelvl =ul;
      |               ~~~~~~            ^

gcc report:
  chpst.c:312:33: warning: operation on 'subgetoptarg' may be undefined [-Wsequence-point]
-rw-r--r--src/chpst.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/chpst.c b/src/chpst.c
index 86032bc..d65e8fd 100644
--- a/src/chpst.c
+++ b/src/chpst.c
@@ -308,7 +308,8 @@ int main(int argc, char **argv) {
     case 'n':
       switch (*optarg) {
         case '-':
-          if (optarg[scan_ulong(++optarg, &ul)]) usage(); nicelvl =ul;
+          ++optarg;
+          if (optarg[scan_ulong(optarg, &ul)]) usage(); nicelvl =ul;
           nicelvl *=-1;
           break;
         case '+': ++optarg;