Skip to content

Commit

Permalink
Fix rdb pipe uninitialized false positive warning
Browse files Browse the repository at this point in the history
After valkey-io#60, the CI report this warning:
```
rdb.c: In function 'rdbSaveToReplicasSockets':
rdb.c:3661:28: error: 'safe_to_exit_pipe' may be used uninitialized [-Werror=maybe-uninitialized]
 3661 |         if (!dual_channel) close(safe_to_exit_pipe);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~
rdb.c:3512:37: note: 'safe_to_exit_pipe' was declared here
 3512 |     int pipefds[2], rdb_pipe_write, safe_to_exit_pipe;
      |                                     ^~~~~~~~~~~~~~~~~
rdb.c:3654:17: error: 'rdb_pipe_write' may be used uninitialized [-Werror=maybe-uninitialized]
 3654 |                 close(rdb_pipe_write); /* close write in parent so that it can detect the close on the child. */
      |                 ^~~~~~~~~~~~~~~~~~~~~
rdb.c:3512:21: note: 'rdb_pipe_write' was declared here
 3512 |     int pipefds[2], rdb_pipe_write, safe_to_exit_pipe;
      |                     ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```

Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Jul 18, 2024
1 parent ff6b780 commit be84531
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3509,7 +3509,7 @@ int rdbSaveToReplicasSockets(int req, rdbSaveInfo *rsi) {
listNode *ln;
listIter li;
pid_t childpid;
int pipefds[2], rdb_pipe_write, safe_to_exit_pipe;
int pipefds[2], rdb_pipe_write = 0, safe_to_exit_pipe = 0;
int dual_channel = (req & REPLICA_REQ_RDB_CHANNEL);

if (hasActiveChildProcess()) return C_ERR;
Expand Down

0 comments on commit be84531

Please sign in to comment.