• sundb's avatar
    Fix compile errors when building with gcc-12 or clang (partial #12035) · f90ecfb1
    sundb authored
    This is a partial cherry-pick from Redis 7.2
    
    ## Fix various compilation warnings and errors
    
    5) server.c
    
    COMPILER: gcc-13 with FORTIFY_SOURCE
    
    WARNING:
    ```
    In function 'lookupCommandLogic',
        inlined from 'lookupCommandBySdsLogic' at server.c:3139:32:
    server.c:3102:66: error: '*(robj **)argv' may be used uninitialized [-Werror=maybe-uninitialized]
     3102 |     struct redisCommand *base_cmd = dictFetchValue(commands, argv[0]->ptr);
          |                                                              ~~~~^~~
    ```
    
    REASON: The compiler thinks that the `argc` returned by `sdssplitlen()` could be 0,
    resulting in an empty array of size 0 being passed to lookupCommandLogic.
    this should be a false positive, `argc` can't be 0 when strings are not NULL.
    
    SOLUTION: add an assert to let the compiler know that `argc` is positive.
    
    ## Other changes
    1) Fixed `ps -p [pid]`  doesn't output `<defunct>` when using procps 4.x causing `replication
      child dies when parent is killed - diskless` test to fail.
    
    (cherry picked from commit 42c8c618)
    f90ecfb1
util.tcl 31.3 KB