]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
watchdog: work around Coverity confusion
authorLennart Poettering <lennart@poettering.net>
Mon, 7 Feb 2022 09:59:05 +0000 (10:59 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 7 Feb 2022 20:48:36 +0000 (20:48 +0000)
Coverity (and I, initially) get really confused about "fn"'s validity
here. it doesn't grok that free_and_strdup() is actually a NOP in case
the string isn't changed, and assumes it always invalidates the
specified buffer, which it doesn't do though.

Follow-up for: f4b1a6b6419b771d26342a9b75b1d77ee9d90133

src/shared/watchdog.c

index e4cc0926f783a65892ea2e5996a403e4e9d8b495..f29d3761b06d1636f506f5c072ce7bc5fdc72e7a 100644 (file)
@@ -137,17 +137,17 @@ static int open_watchdog(void) {
         if (r < 0)
                 return log_oom_debug();
 
-        watchdog_fd = open(fn, O_WRONLY|O_CLOEXEC);
+        watchdog_fd = open(watchdog_device, O_WRONLY|O_CLOEXEC);
         if (watchdog_fd < 0)
-                return log_debug_errno(errno, "Failed to open watchdog device %s, ignoring: %m", fn);
+                return log_debug_errno(errno, "Failed to open watchdog device %s, ignoring: %m", watchdog_device);
 
         if (ioctl(watchdog_fd, WDIOC_GETSUPPORT, &ident) < 0)
-                log_debug_errno(errno, "Hardware watchdog %s does not support WDIOC_GETSUPPORT ioctl, ignoring: %m", fn);
+                log_debug_errno(errno, "Hardware watchdog %s does not support WDIOC_GETSUPPORT ioctl, ignoring: %m", watchdog_device);
         else
                 log_info("Using hardware watchdog '%s', version %x, device %s",
                          ident.identity,
                          ident.firmware_version,
-                         fn);
+                         watchdog_device);
 
         r = update_timeout();
         if (r < 0)