]> Savannah Git Hosting - gnulib.git/commitdiff
javacomp: Silence -Wanalyzer-possible-null-argument warning.
authorBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 18:11:57 +0000 (20:11 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 18:25:50 +0000 (20:25 +0200)
* lib/javacomp.c: Include verify.h.
(is_envjavac_gcj43_usable, is_envjavac_oldgcj_14_13_usable,
is_envjavac_nongcj_usable, compile_java_class): Assert that the
xasprintf results are non-NULL. This is possible since all involved
format strings are valid and don't use %ls, and all argument strings
are small compared to INT_MAX.
* modules/javacomp (Depends-on): Add verify.

ChangeLog
lib/javacomp.c
modules/javacomp

index 69e7f19cea4212f17821a24fc2dc56ed6f603788..fbe73fc047a5e3d3ec7a347d7a5ebba3c5dd8e30 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-06-02  Bruno Haible  <bruno@clisp.org>
+
+       javacomp: Silence -Wanalyzer-possible-null-argument warning.
+       * lib/javacomp.c: Include verify.h.
+       (is_envjavac_gcj43_usable, is_envjavac_oldgcj_14_13_usable,
+       is_envjavac_nongcj_usable, compile_java_class): Assert that the
+       xasprintf results are non-NULL. This is possible since all involved
+       format strings are valid and don't use %ls, and all argument strings
+       are small compared to INT_MAX.
+       * modules/javacomp (Depends-on): Add verify.
+
 2023-06-02  Bruno Haible  <bruno@clisp.org>
 
        striconveha: Don't crash if malloc() returns NULL.
index 802742dd95ab8a62a89dc26e22fdbe5b3a69380c..bb4ef919f425af98707d0ac203f527bfe0afcd5f 100644 (file)
@@ -46,6 +46,7 @@
 #include "clean-temp.h"
 #include "error.h"
 #include "xvasprintf.h"
+#include "verify.h"
 #include "c-strstr.h"
 #include "gettext.h"
 
@@ -849,6 +850,7 @@ is_envjavac_gcj43_usable (const char *javac,
           /* Try adding -fsource option if it is useful.  */
           char *javac_source =
             xasprintf ("%s -fsource=%s", javac, source_version);
+          assume (javac_source != NULL);
 
           unlink (compiled_file_name);
 
@@ -917,6 +919,7 @@ is_envjavac_gcj43_usable (const char *javac,
           char *javac_target =
             xasprintf ("%s -fsource=%s -ftarget=%s",
                        javac, source_version, target_version);
+          assume (javac_target != NULL);
 
           unlink (compiled_file_name);
 
@@ -1060,6 +1063,7 @@ is_envjavac_oldgcj_14_13_usable (const char *javac,
       unlink (compiled_file_name);
 
       javac_noassert = xasprintf ("%s -fno-assert", javac);
+      assume (javac_noassert != NULL);
 
       java_sources[0] = conftest_file_name;
       if (!compile_using_envjavac (javac_noassert,
@@ -1200,6 +1204,7 @@ is_envjavac_nongcj_usable (const char *javac,
           /* Try adding -source option if it is useful.  */
           char *javac_source =
             xasprintf ("%s -source %s", javac, source_version_for_javac);
+          assume (javac_source != NULL);
 
           unlink (compiled_file_name);
 
@@ -1268,6 +1273,7 @@ is_envjavac_nongcj_usable (const char *javac,
              option but no -source option.)  */
           char *javac_target =
             xasprintf ("%s -target %s", javac, target_version);
+          assume (javac_target != NULL);
 
           unlink (compiled_file_name);
 
@@ -1284,6 +1290,7 @@ is_envjavac_nongcj_usable (const char *javac,
               /* Try adding -source option if it is useful.  */
               char *javac_target_source =
                 xasprintf ("%s -source %s", javac_target, source_version_for_javac);
+              assume (javac_target_source != NULL);
 
               unlink (compiled_file_name);
 
@@ -1358,6 +1365,7 @@ is_envjavac_nongcj_usable (const char *javac,
                  higher.)  */
               char *javac_target_source =
                 xasprintf ("%s -source %s", javac_target, source_version_for_javac);
+              assume (javac_target_source != NULL);
 
               unlink (compiled_file_name);
 
@@ -2267,6 +2275,7 @@ compile_java_class (const char * const *java_sources,
                             fsource_option ? source_version : "",
                             ftarget_option ? " -ftarget=" : "",
                             ftarget_option ? target_version : ""));
+            assume (javac_with_options != NULL);
 
             err = compile_using_envjavac (javac_with_options,
                                           java_sources, java_sources_count,
index cdd6473c4e748930b087bbff00e56c9a7035fbdb..f3ce944100d516b8fe3d8a916da4da3589245d16 100644 (file)
@@ -28,6 +28,7 @@ clean-temp
 stat
 error
 xvasprintf
+verify
 c-strstr
 gettext-h
 javacomp-script