Fix two scan-build warnings that appear on F41
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 23 Dec 2024 07:13:06 +0000 (17:13 +1000)
committerMarge Bot <emma+marge@anholt.net>
Mon, 23 Dec 2024 07:17:31 +0000 (07:17 +0000)
../../../src/util-files.h:61:3: warning: The 1st argument to 'close' is <= -2 but should be >= -1 [unix.StdCLibraryFunctions]
   61 |                 close(*fd);

 ../../../test/test-quirks.c:66:8: warning: Null pointer passed to 2nd parameter expecting 'nonnull' [core.NonNullParamChecker]
   66 |                 rc = fputs(file_content, fp);

The latter is bogus because we have a litest_assert for this but
somehow this is ignored, so... shrug.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1111>

src/util-files.h
test/test-quirks.c

index e980d0991cf18e6b9e0283f0027ea6806fcb670d..38e151a51a513963d81dbbcc28c64af14839a257 100644 (file)
@@ -57,7 +57,7 @@ mkdir_p(const char *dir)
 static inline void
 xclose(int *fd)
 {
-       if (*fd != -1) {
+       if (*fd > -1) {
                close(*fd);
                *fd = -1;
        }
index 0d92e6d6e67b309071e02019883619a5c30ee3ed..7a1571eab7b57f10bc8db728af7258af32d86ce1 100644 (file)
@@ -62,7 +62,11 @@ make_data_dir(const char *file_content)
                litest_assert_int_eq(rc, (int)(strlen(dirname) + 16));
 
                fp = fopen(filename, "w+");
+#ifndef __clang_analyzer__
                litest_assert_notnull(fp);
+#else
+               assert(fp);
+#endif
                rc = fputs(file_content, fp);
                litest_assert_errno_success(rc);
                fclose(fp);