mirror of https://mirror.osredm.com/root/redis.git
Fix compile errors when building with gcc-12 or clang (partial #12035)
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 42c8c61813
)
This commit is contained in:
parent
bd1dac0c6e
commit
f90ecfb1f7
|
@ -3060,6 +3060,7 @@ struct redisCommand *lookupCommandBySdsLogic(dict *commands, sds s) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
serverAssert(argc > 0); /* Avoid warning `-Wmaybe-uninitialized` in lookupCommandLogic() */
|
||||
robj objects[argc];
|
||||
robj *argv[argc];
|
||||
for (j = 0; j < argc; j++) {
|
||||
|
|
|
@ -634,7 +634,7 @@ proc get_child_pid {idx} {
|
|||
}
|
||||
|
||||
proc process_is_alive pid {
|
||||
if {[catch {exec ps -p $pid} err]} {
|
||||
if {[catch {exec ps -p $pid -f} err]} {
|
||||
return 0
|
||||
} else {
|
||||
if {[string match "*<defunct>*" $err]} { return 0 }
|
||||
|
|
Loading…
Reference in New Issue