Fix the build error for gcc-14 62/312362/1 accepted/tizen_unified accepted/tizen_unified_dev accepted/tizen_unified_toolchain accepted/tizen_unified_x accepted/tizen_unified_x_asan tizen accepted/tizen/unified/20240611.123341 accepted/tizen/unified/dev/20240620.011133 accepted/tizen/unified/toolchain/20240610.172956 accepted/tizen/unified/x/20240610.223526 accepted/tizen/unified/x/asan/20240625.092733
authorJaehyun Kim <jeik01.kim@samsung.com>
Fri, 7 Jun 2024 09:11:13 +0000 (18:11 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Fri, 7 Jun 2024 09:12:26 +0000 (18:12 +0900)
Change-Id: I9dca705f49f9c4a993bccc3911db6f527cd99c8e
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
configure
configure.ac

index 5f055d2..eaa003c 100755 (executable)
--- a/configure
+++ b/configure
 
 
 #
-# Check for <inttypes.h>
+# It became apparent at some point that using a suitable C99 compiler does not
+# automatically mean snprintf(3) implementation in the libc supports all the
+# modifiers and specifiers used in the project, so let's test that before the
+# build, not after.
 #
-for ac_header in inttypes.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default"
-if test "x$ac_cv_header_inttypes_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_INTTYPES_H 1
-_ACEOF
-
-    #
-    # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
-    # Some systems have an inttypes.h that doesn't define all of them.
-    #
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether inttypes.h defines the PRI[doxu]64 macros" >&5
-$as_echo_n "checking whether inttypes.h defines the PRI[doxu]64 macros... " >&6; }
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-
-           #include <inttypes.h>
-           #include <stdio.h>
-           #include <sys/types.h>
-
-           main()
-           {
-             printf("%" PRId64 "\n", (uint64_t)1);
-             printf("%" PRIo64 "\n", (uint64_t)1);
-             printf("%" PRIx64 "\n", (uint64_t)1);
-             printf("%" PRIu64 "\n", (uint64_t)1);
-           }
-
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-       ac_lbl_inttypes_h_defines_formats=yes
-
-else
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-       ac_lbl_inttypes_h_defines_formats=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-else
-
-    #
-    # We don't have inttypes.h, so it obviously can't define those
-    # macros.
-    #
-    ac_lbl_inttypes_h_defines_formats=no
-
-fi
-
-done
-
-if test "$ac_lbl_inttypes_h_defines_formats" = no; then
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether %lx can be used to format 64-bit integers" >&5
-$as_echo_n "checking whether %lx can be used to format 64-bit integers... " >&6; }
-    if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-
-#          ifdef HAVE_INTTYPES_H
-           #include <inttypes.h>
-#          endif
-           #include <stdio.h>
-           #include <sys/types.h>
-
-           main()
-           {
-             uint64_t t = 1;
-             char strbuf[16+1];
-             sprintf(strbuf, "%016lx", t << 32);
-             if (strcmp(strbuf, "0000000100000000") == 0)
-               exit(0);
-             else
-               exit(1);
-           }
-
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-
-$as_echo "#define PRId64 \"ld\"" >>confdefs.h
-
-
-$as_echo "#define PRIo64 \"lo\"" >>confdefs.h
-
-
-$as_echo "#define PRIx64 \"lx\"" >>confdefs.h
-
-
-$as_echo "#define PRIu64 \"lu\"" >>confdefs.h
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-else
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether %llx can be used to format 64-bit integers" >&5
-$as_echo_n "checking whether %llx can be used to format 64-bit integers... " >&6; }
-    if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-
-#          ifdef HAVE_INTTYPES_H
-           #include <inttypes.h>
-#          endif
-           #include <stdio.h>
-           #include <sys/types.h>
-
-           main()
-           {
-             uint64_t t = 1;
-             char strbuf[16+1];
-             sprintf(strbuf, "%016llx", t << 32);
-             if (strcmp(strbuf, "0000000100000000") == 0)
-               exit(0);
-             else
-               exit(1);
-           }
-
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-
-$as_echo "#define PRId64 \"lld\"" >>confdefs.h
-
-
-$as_echo "#define PRIo64 \"llo\"" >>confdefs.h
-
-
-$as_echo "#define PRIx64 \"llx\"" >>confdefs.h
-
+# Testing the sizeof_t length modifier takes making an snprintf() call and
+# comparing the actual result with the expected result.  If this fails, it will
+# most likely happen at run time, not compile time.
+#
+# Testing the 64-bit conversion specifiers in addition to that requires the
+# <inttypes.h> header to be present and the macros to be defined, so if this
+# fails, it will more likely happen at compile time.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf is suitable" >&5
+$as_echo_n "checking whether snprintf is suitable... " >&6; }
+if test "$cross_compiling" = yes; then :
 
-$as_echo "#define PRIu64 \"llu\"" >>confdefs.h
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not while cross-compiling" >&5
+$as_echo "not while cross-compiling" >&6; }
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
 
 else
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether %Lx can be used to format 64-bit integers" >&5
-$as_echo_n "checking whether %Lx can be used to format 64-bit integers... " >&6; }
-    if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
-#          ifdef HAVE_INTTYPES_H
-           #include <inttypes.h>
-#          endif
-           #include <stdio.h>
-           #include <sys/types.h>
-
-           main()
-           {
-             uint64_t t = 1;
-             char strbuf[16+1];
-             sprintf(strbuf, "%016Lx", t << 32);
-             if (strcmp(strbuf, "0000000100000000") == 0)
-               exit(0);
-             else
-               exit(1);
-           }
-
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-
-$as_echo "#define PRId64 \"Ld\"" >>confdefs.h
-
-
-$as_echo "#define PRIo64 \"Lo\"" >>confdefs.h
-
-
-$as_echo "#define PRIx64 \"Lx\"" >>confdefs.h
-
-
-$as_echo "#define PRIu64 \"Lu\"" >>confdefs.h
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <sys/types.h>
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+int main()
+{
+  char buf[100];
+  uint64_t t = (uint64_t)1 << 32;
 
-else
+  snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
+  if (strncmp(buf, "100", sizeof(buf)))
+    return 1;
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  snprintf(buf, sizeof(buf), "%zd", -sizeof(buf));
+  if (strncmp(buf, "-100", sizeof(buf)))
+    return 2;
 
+  snprintf(buf, sizeof(buf), "%" PRId64, -t);
+  if (strncmp(buf, "-4294967296", sizeof(buf)))
+    return 3;
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether %qx can be used to format 64-bit integers" >&5
-$as_echo_n "checking whether %qx can be used to format 64-bit integers... " >&6; }
-    if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+  snprintf(buf, sizeof(buf), "0o%" PRIo64, t);
+  if (strncmp(buf, "0o40000000000", sizeof(buf)))
+    return 4;
 
+  snprintf(buf, sizeof(buf), "0x%" PRIx64, t);
+  if (strncmp(buf, "0x100000000", sizeof(buf)))
+    return 5;
 
-#          ifdef HAVE_INTTYPES_H
-           #include <inttypes.h>
-#          endif
-           #include <stdio.h>
-           #include <sys/types.h>
+  snprintf(buf, sizeof(buf), "%" PRIu64, t);
+  if (strncmp(buf, "4294967296", sizeof(buf)))
+    return 6;
 
-           main()
-           {
-             uint64_t t = 1;
-             char strbuf[16+1];
-             sprintf(strbuf, "%016qx", t << 32);
-             if (strcmp(strbuf, "0000000100000000") == 0)
-               exit(0);
-             else
-               exit(1);
-           }
+  return 0;
+}
 
 
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
 
-
-$as_echo "#define PRId64 \"qd\"" >>confdefs.h
-
-
-$as_echo "#define PRIo64 \"qo\"" >>confdefs.h
-
-
-$as_echo "#define PRIx64 \"qx\"" >>confdefs.h
-
-
-$as_echo "#define PRIu64 \"qu\"" >>confdefs.h
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
 else
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-
-                 as_fn_error $? "neither %llx nor %Lx nor %qx worked on a 64-bit integer" "$LINENO" 5
-
-
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-
-
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-
+        as_fn_error $? "The snprintf(3) implementation in this libc is not suitable,
+tcpdump would not work correctly even if it managed to compile." "$LINENO" 5
 
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
@@ -6862,16 +6642,6 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
 fi
 
 
-
-
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-
 #
 # Check for some headers introduced in later versions of libpcap
 # and used by some printers.
index 56e2a62..e077285 100644 (file)
@@ -783,63 +783,74 @@ AC_CHECK_TYPE([u_int64_t], ,
 ])
 
 #
-# Check for <inttypes.h>
-#
-AC_CHECK_HEADERS(inttypes.h,
-  [
-    #
-    # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
-    # Some systems have an inttypes.h that doesn't define all of them.
-    #
-    AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
-    AC_COMPILE_IFELSE(
-      [
-       AC_LANG_SOURCE(
-         [[
-           #include <inttypes.h>
-           #include <stdio.h>
-           #include <sys/types.h>
-
-           main()
-           {
-             printf("%" PRId64 "\n", (uint64_t)1);
-             printf("%" PRIo64 "\n", (uint64_t)1);
-             printf("%" PRIx64 "\n", (uint64_t)1);
-             printf("%" PRIu64 "\n", (uint64_t)1);
-           }
-         ]])
-      ],
-      [
-       AC_MSG_RESULT(yes)
-       ac_lbl_inttypes_h_defines_formats=yes
-      ],
-      [
-       AC_MSG_RESULT(no)
-       ac_lbl_inttypes_h_defines_formats=no
-      ])
-  ],
-  [
-    #
-    # We don't have inttypes.h, so it obviously can't define those
-    # macros.
-    #
-    ac_lbl_inttypes_h_defines_formats=no
-  ])
-if test "$ac_lbl_inttypes_h_defines_formats" = no; then
-  AC_LBL_CHECK_64BIT_FORMAT(l,
+# It became apparent at some point that using a suitable C99 compiler does not
+# automatically mean snprintf(3) implementation in the libc supports all the
+# modifiers and specifiers used in the project, so let's test that before the
+# build, not after.
+#
+# Testing the sizeof_t length modifier takes making an snprintf() call and
+# comparing the actual result with the expected result.  If this fails, it will
+# most likely happen at run time, not compile time.
+#
+# Testing the 64-bit conversion specifiers in addition to that requires the
+# <inttypes.h> header to be present and the macros to be defined, so if this
+# fails, it will more likely happen at compile time.
+#
+AC_MSG_CHECKING([whether snprintf is suitable])
+AC_RUN_IFELSE(
     [
-      AC_LBL_CHECK_64BIT_FORMAT(ll,
-        [
-          AC_LBL_CHECK_64BIT_FORMAT(L,
-           [
-             AC_LBL_CHECK_64BIT_FORMAT(q,
-               [
-                 AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
-               ])
-           ])
-       ])
-    ])
-fi
+        AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <sys/types.h>
+
+int main()
+{
+  char buf[100];
+  uint64_t t = (uint64_t)1 << 32;
+
+  snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
+  if (strncmp(buf, "100", sizeof(buf)))
+    return 1;
+
+  snprintf(buf, sizeof(buf), "%zd", -sizeof(buf));
+  if (strncmp(buf, "-100", sizeof(buf)))
+    return 2;
+
+  snprintf(buf, sizeof(buf), "%" PRId64, -t);
+  if (strncmp(buf, "-4294967296", sizeof(buf)))
+    return 3;
+
+  snprintf(buf, sizeof(buf), "0o%" PRIo64, t);
+  if (strncmp(buf, "0o40000000000", sizeof(buf)))
+    return 4;
+
+  snprintf(buf, sizeof(buf), "0x%" PRIx64, t);
+  if (strncmp(buf, "0x100000000", sizeof(buf)))
+    return 5;
+
+  snprintf(buf, sizeof(buf), "%" PRIu64, t);
+  if (strncmp(buf, "4294967296", sizeof(buf)))
+    return 6;
+
+  return 0;
+}
+        ]])
+    ],
+    [
+        AC_MSG_RESULT(yes)
+    ],
+    [
+        AC_MSG_RESULT(no)
+        AC_MSG_ERROR(
+[The snprintf(3) implementation in this libc is not suitable,
+tcpdump would not work correctly even if it managed to compile.])
+    ],
+    [
+        AC_MSG_RESULT(not while cross-compiling)
+    ]
+)
 
 #
 # Check for some headers introduced in later versions of libpcap