]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
linux: default init cleanup variable
authorDaniel Wagner <dwagner@suse.de>
Fri, 10 May 2024 11:30:53 +0000 (13:30 +0200)
committerDaniel Wagner <wagi@monom.org>
Fri, 10 May 2024 11:39:19 +0000 (13:39 +0200)
gcc sometimes has troubles to figure out if a variable is used without
initialization when using the cleanup helpers.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/nvme/linux.c
src/nvme/tree.c

index 5c48671a87efc5e420c90f612f43c9df36199d01..095c06554960abc9a7fb34ce646477b104709782 100644 (file)
@@ -296,8 +296,8 @@ int nvme_get_new_host_telemetry(int fd, struct nvme_telemetry_log **log,
 
 int nvme_get_lba_status_log(int fd, bool rae, struct nvme_lba_status_log **log)
 {
+       _cleanup_free_ struct nvme_lba_status_log *buf = NULL;
        __u32 size;
-       _cleanup_free_ struct nvme_lba_status_log *buf;
        void *tmp;
        int err;
        struct nvme_get_log_args args = {
index d3ce49d83fd879da2f5427f672628947d912dbf5..27363f53e51c281966adafd9bde8a66c02066835 100644 (file)
@@ -1601,8 +1601,8 @@ nvme_ctrl_t __nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport,
                               const char *host_iface, const char *trsvcid,
                               const char *subsysnqn, nvme_ctrl_t p)
 {
+       _cleanup_candidate_ struct candidate_args candidate = {};
        struct nvme_ctrl *c, *matching_c = NULL;
-       _cleanup_candidate_ struct candidate_args candidate;
        ctrl_match_t ctrl_match;
 
        /* Init candidate and get the matching function to use */
@@ -1625,8 +1625,8 @@ bool nvme_ctrl_config_match(struct nvme_ctrl *c, const char *transport,
                            const char *subsysnqn, const char *host_traddr,
                            const char *host_iface)
 {
+       _cleanup_candidate_ struct candidate_args candidate = {};
        ctrl_match_t ctrl_match;
-       _cleanup_candidate_ struct candidate_args candidate;
 
        /* Init candidate and get the matching function to use */
        ctrl_match = _candidate_init(&candidate, transport, traddr, trsvcid,