Suppress statement not reached warnings under Solaris Studio 58/12958/2
authorMichael Meffie <mmeffie@sinenomine.net>
Sun, 21 Jan 2018 23:38:11 +0000 (18:38 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Sat, 17 Mar 2018 20:40:06 +0000 (16:40 -0400)
Solaris Studio issues warnings for statements which can not be reached,
such as statements following an infinite loop.  For example, the return
statement will generate a 'statement not reached' warning in the
following code:

    while (1) {
       /*  no breaks or gotos in this body */
    }
    return 0;

Suppress these warnings by conditionally removing such statements when
building under Solaris Studio.

Change-Id: Ib4f465bf9c00eff0d603e5bd643db7d3a5aa0ba0
Reviewed-on: https://gerrit.openafs.org/12958
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

19 files changed:
src/bozo/bnode.c
src/bozo/bosserver.c
src/bucoord/bc_status.c
src/butc/dbentries.c
src/config/stds.h
src/fsprobe/fsprobe.c
src/kauth/krb_udp.c
src/lwp/iomgr.c
src/opr/softsig.c
src/rx/rx_lwp.c
src/rx/rx_pthread.c
src/ubik/beacon.c
src/ubik/recovery.c
src/util/tabular_output.c
src/viced/viced.c
src/vol/fssync-server.c
src/vol/salvaged.c
src/vol/salvsync-server.c
src/volser/volmain.c

index d117311..6c0ab90 100644 (file)
@@ -681,7 +681,7 @@ bproc(void *unused)
            }
        }
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static afs_int32
index f97745c..fb586f7 100644 (file)
@@ -633,7 +633,7 @@ BozoDaemon(void *unused)
            bnode_ApplyInstance(bdrestart, 0);
        }
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 #ifdef AFS_AIX32_ENV
index 818cc58..2ba8728 100644 (file)
@@ -388,7 +388,7 @@ statusWatcher(void *unused)
            curPollPtr = 0;
        }                       /*done */
     }                          /*w */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /* bc_jobNumber
index 3a358ce..37b35d3 100644 (file)
@@ -483,5 +483,5 @@ dbWatcher(void *unused)
        IOMGR_Sleep(2);
 #endif
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
index a031bfd..0185623 100644 (file)
@@ -316,4 +316,13 @@ hdr_static_inline(unsigned long long) afs_printable_uint64_lu(afs_uint64 d) { re
 #define AFS_NONNULL(x)
 #endif
 
+/*
+ * Conditionally remove unreached statements under Solaris Studio.
+ */
+#if defined(__SUNPRO_C)
+# define AFS_UNREACHED(x)
+#else
+# define AFS_UNREACHED(x)  x
+#endif
+
 #endif /* OPENAFS_CONFIG_AFS_STDS_H */
index 1ca1b5a..03657eb 100644 (file)
@@ -367,9 +367,8 @@ fsprobe_LWP(void *unused)
        if (code)
            fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn, code);
     }                          /*Service loop */
-    free(stats64.ViceStatistics64_val);
-
-    return NULL;
+    AFS_UNREACHED(free(stats64.ViceStatistics64_val));
+    AFS_UNREACHED(return(NULL));
 }                              /*fsprobe_LWP */
 
 /*list all the partitions on <aserver> */
index f4b8477..a5960f3 100644 (file)
@@ -113,7 +113,7 @@ FiveMinuteCheckLWP(void *unused)
        /* close the log so it can be removed */
        ReOpenLog();    /* no trunc, just append */
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 
index dcd94d1..821ae0c 100644 (file)
@@ -583,7 +583,7 @@ static void *IOMGR(void *dummy)
        }
        LWP_DispatchProcess();
     }
-    return (void *)-1; /* keeps compilers happy. */
+    AFS_UNREACHED(return((void *)-1)); /* keeps compilers happy. */
 }
 
 /************************\
index 469bd43..fa4fcad 100644 (file)
@@ -76,7 +76,7 @@ signalHandler(void *arg)
            handlers[receivedSignal].handler(receivedSignal);
        }
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static void
index fa4ee6d..a64f3be 100644 (file)
@@ -334,8 +334,7 @@ rx_ListenerProc(void *dummy)
        rxi_ServerProc(threadID, newcall, &sock);
        /* osi_Assert(sock != OSI_NULLSOCKET); */
     }
-    /* not reached */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /* This is the server process request loop. The server process loop
@@ -368,8 +367,7 @@ rx_ServerProc(void * unused)
        /* osi_Assert(threadID != -1); */
        /* osi_Assert(newcall != NULL); */
     }
-    /* not reached */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /*
index b4272bb..ba824b7 100644 (file)
@@ -182,7 +182,7 @@ event_handler(void *argp)
 #endif
        rx_pthread_event_rescheduled = 0;
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 
@@ -264,8 +264,7 @@ rx_ListenerProc(void *argp)
        rxi_ServerProc(threadID, newcall, &sock);
        /* osi_Assert(sock != OSI_NULLSOCKET); */
     }
-    /* not reached */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /* This is the server process request loop. The server process loop
@@ -312,8 +311,7 @@ rx_ServerProc(void * dummy)
        /* osi_Assert(threadID != -1); */
        /* osi_Assert(newcall != NULL); */
     }
-    /* not reached */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /*
index 01844ae..4351cc8 100644 (file)
@@ -663,7 +663,7 @@ ubeacon_Interact(void *dummy)
        }
 
     }                          /* while loop */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /*!
index 0f3e714..5bd03e1 100644 (file)
@@ -874,7 +874,7 @@ urecovery_Interact(void *dummy)
        }
        DBRELE(ubik_dbase);
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /*!
index 7c883a8..dd45fd2 100644 (file)
@@ -509,5 +509,5 @@ findRowIndex(struct util_Table* Table, struct util_TableRow *aRow){
                 return lower;
         }
     }  while(1);
-    return 0;
+    AFS_UNREACHED(return(0));
 }
index 11f21e0..1ca05a6 100644 (file)
@@ -440,8 +440,10 @@ FiveMinuteCheckLWP(void *unused)
     opr_cv_broadcast(&fs_state.worker_done_cv);
     FS_UNLOCK;
     FS_STATE_UNLOCK;
-#endif
     return NULL;
+#else
+    AFS_UNREACHED(return(NULL));
+#endif
 }                              /*FiveMinuteCheckLWP */
 
 
@@ -488,8 +490,10 @@ HostCheckLWP(void *unused)
     opr_cv_broadcast(&fs_state.worker_done_cv);
     FS_UNLOCK;
     FS_STATE_UNLOCK;
-#endif
     return NULL;
+#else
+    AFS_UNREACHED(return(NULL));
+#endif
 }                              /*HostCheckLWP */
 
 /* This LWP does fsync checks every 5 minutes:  it should not be used for
@@ -547,8 +551,10 @@ FsyncCheckLWP(void *unused)
     opr_cv_broadcast(&fs_state.worker_done_cv);
     FS_UNLOCK;
     FS_STATE_UNLOCK;
-#endif /* AFS_DEMAND_ATTACH_FS */
     return NULL;
+#else
+    AFS_UNREACHED(return(NULL));
+#endif /* !AFS_DEMAND_ATTACH_FS */
 }
 
 /*------------------------------------------------------------------------
@@ -2213,5 +2219,5 @@ main(int argc, char *argv[])
     while (1) {
        sleep(1000);            /* long time */
     }
-    return 0;
+    AFS_UNREACHED(return(0));
 }
index cd15e2d..2d7cd60 100644 (file)
@@ -331,7 +331,7 @@ FSYNC_sync(void * args)
            CallHandler(&FSYNC_readfds);
 #endif
     }
-    return NULL; /* hush now, little gcc */
+    AFS_UNREACHED(return(NULL)); /* hush now, little gcc */
 }
 
 #ifdef AFS_DEMAND_ATTACH_FS
@@ -376,9 +376,8 @@ FSYNC_salvageThread(void * args)
        VCancelReservation_r(vp);
     }
 
-    VOL_UNLOCK;
-
-    return NULL;
+    AFS_UNREACHED(VOL_UNLOCK);
+    AFS_UNREACHED(return(NULL));
 }
 
 /**
@@ -2128,7 +2127,7 @@ FindHandler(osi_socket afd)
        }
     ReleaseReadLock(&FSYNC_handler_lock);      /* just in case */
     opr_abort();
-    return -1;                 /* satisfy compiler */
+    AFS_UNREACHED(return(-1));                 /* satisfy compiler */
 }
 
 static int
@@ -2140,7 +2139,7 @@ FindHandler_r(osi_socket afd)
            return i;
        }
     opr_abort();
-    return -1;                 /* satisfy compiler */
+    AFS_UNREACHED(return(-1));                 /* satisfy compiler */
 }
 
 static int
index 23239d7..b246831 100644 (file)
@@ -708,7 +708,7 @@ SalvageChildReaperThread(void * args)
        opr_cv_broadcast(&worker_cv);
     }
 
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static int
@@ -757,8 +757,8 @@ SalvageLogCleanupThread(void * arg)
        }
     }
 
-    opr_mutex_exit(&worker_lock);
-    return NULL;
+    AFS_UNREACHED(opr_mutex_exit(&worker_lock));
+    AFS_UNREACHED(return(NULL));
 }
 
 #define LOG_XFER_BUF_SIZE 65536
index b399d81..d974152 100644 (file)
@@ -336,7 +336,7 @@ SALVSYNC_syncThread(void * args)
            CallHandler(&SALVSYNC_readfds);
     }
 
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static void
index f454dd1..de3c986 100644 (file)
@@ -156,7 +156,7 @@ BKGLoop(void *unused)
        }
     }
 
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 #if defined(AFS_NT40_ENV) || defined(AFS_DARWIN160_ENV)