libadmin: appease clang -Wsometimes-uninitialized 76/13476/2
authorBenjamin Kaduk <kaduk@mit.edu>
Sun, 3 Feb 2019 01:52:26 +0000 (19:52 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 1 Mar 2019 14:06:37 +0000 (09:06 -0500)
clang thinks that 'time' can be used uninitialized:

bos.c:1472:9: error: variable 'time' is used uninitialized whenever 'if' condition is
      false [-Werror,-Wsometimes-uninitialized]
    if (as->parms[TIME].items) {
        ^~~~~~~~~~~~~~~~~~~~~
bos.c:1478:57: note: uninitialized use occurs here
    if (!bos_ExecutableRestartTimeSet(bos_server, type, time, &st)) {
                                                        ^~~~
bos.c:1472:5: note: remove the 'if' if its condition is always true
    if (as->parms[TIME].items) {
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
bos.c:1445:5: note: variable 'time' is declared here
    bos_RestartTime_t time;
    ^

but in this command description, the TIME argument is required.
Add a never-triggered error exit to appease the compiler when
--enable-checking is activated.

Change-Id: I38fac64fc5aba071f84f2f9e1b497df22df76f09
Reviewed-on: https://gerrit.openafs.org/13476
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/libadmin/test/bos.c

index 4da7879..92b25cb 100644 (file)
@@ -1473,6 +1473,8 @@ DoBosExecutableRestartTimeSet(struct cmd_syndesc *as, void *arock)
        if (ktime_ParsePeriodic(as->parms[TIME].items->data, &time) == -1) {
            ERR_EXT("error parsing time");
        }
+    } else {
+       ERR_EXT("Mandatory time argument not supplied");
     }
 
     if (!bos_ExecutableRestartTimeSet(bos_server, type, time, &st)) {