mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-08 12:38:01 +02:00
Add DBUS_INT64_MODIFIER define, turn on -Wformat
https://bugs.freedesktop.org/show_bug.cgi?id=19195 We were previously using -Wno-format because we didn't have a #define for DBUS_INT64_MODIFIER, which was really lame because it easily hid problems. For now, just define it if we're on glibc; this is obviously not strictly correct but it's safe, because the formatting is only used in DBUS_VERBOSE mode, and in tools/dbus-monitor. Ideally we get the the glib code relicensed.
This commit is contained in:
parent
03bb3ce656
commit
c93d3ec2ff
6 changed files with 53 additions and 21 deletions
45
configure.in
45
configure.in
|
|
@ -146,6 +146,31 @@ if test x$enable_gcov = xyes; then
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(DBUS_GCOV_ENABLED, test x$enable_gcov = xyes)
|
AM_CONDITIONAL(DBUS_GCOV_ENABLED, test x$enable_gcov = xyes)
|
||||||
|
|
||||||
|
# glibc21.m4 serial 3
|
||||||
|
dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc.
|
||||||
|
dnl This file is free software; the Free Software Foundation
|
||||||
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
|
dnl with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# Test for the GNU C Library, version 2.1 or newer.
|
||||||
|
# From Bruno Haible.
|
||||||
|
|
||||||
|
AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
|
||||||
|
ac_cv_gnu_library_2_1,
|
||||||
|
[AC_EGREP_CPP([Lucky GNU user],
|
||||||
|
[
|
||||||
|
#include <features.h>
|
||||||
|
#ifdef __GNU_LIBRARY__
|
||||||
|
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
|
||||||
|
Lucky GNU user
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
],
|
||||||
|
ac_cv_gnu_library_2_1=yes,
|
||||||
|
ac_cv_gnu_library_2_1=no)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
#### Integer sizes
|
#### Integer sizes
|
||||||
|
|
||||||
AC_CHECK_SIZEOF(char)
|
AC_CHECK_SIZEOF(char)
|
||||||
|
|
@ -164,21 +189,32 @@ $ac_cv_sizeof_int)
|
||||||
dbusint64=int
|
dbusint64=int
|
||||||
dbusint64_constant='(val)'
|
dbusint64_constant='(val)'
|
||||||
dbusuint64_constant='(val)'
|
dbusuint64_constant='(val)'
|
||||||
|
dbusint64_printf_modifier='""'
|
||||||
;;
|
;;
|
||||||
$ac_cv_sizeof_long)
|
$ac_cv_sizeof_long)
|
||||||
dbusint64=long
|
dbusint64=long
|
||||||
dbusint64_constant='(val##L)'
|
dbusint64_constant='(val##L)'
|
||||||
dbusuint64_constant='(val##UL)'
|
dbusuint64_constant='(val##UL)'
|
||||||
|
dbusint64_printf_modifier='"l"'
|
||||||
;;
|
;;
|
||||||
$ac_cv_sizeof_long_long)
|
$ac_cv_sizeof_long_long)
|
||||||
dbusint64='long long'
|
dbusint64='long long'
|
||||||
dbusint64_constant='(val##LL)'
|
dbusint64_constant='(val##LL)'
|
||||||
dbusuint64_constant='(val##ULL)'
|
dbusuint64_constant='(val##ULL)'
|
||||||
|
# Ideally we discover what the format is, but this is
|
||||||
|
# only used in verbose mode, so eh...
|
||||||
|
if test x"$ac_cv_gnu_library_2_1" = xyes; then
|
||||||
|
dbusint64_printf_modifier='"ll"'
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
$ac_cv_sizeof___int64)
|
$ac_cv_sizeof___int64)
|
||||||
dbusint64=__int64
|
dbusint64=__int64
|
||||||
dbusint64_constant='(val##i64)'
|
dbusint64_constant='(val##i64)'
|
||||||
dbusuint64_constant='(val##ui64)'
|
dbusuint64_constant='(val##ui64)'
|
||||||
|
# See above case
|
||||||
|
if test x"$ac_cv_gnu_library_2_1" = xyes; then
|
||||||
|
dbusint64_printf_modifier='"ll"'
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
@ -193,6 +229,9 @@ else
|
||||||
DBUS_HAVE_INT64=1
|
DBUS_HAVE_INT64=1
|
||||||
DBUS_INT64_CONSTANT="$dbusint64_constant"
|
DBUS_INT64_CONSTANT="$dbusint64_constant"
|
||||||
DBUS_UINT64_CONSTANT="$dbusuint64_constant"
|
DBUS_UINT64_CONSTANT="$dbusuint64_constant"
|
||||||
|
if test x"$dbusint64_printf_modifier" != x; then
|
||||||
|
AC_DEFINE_UNQUOTED(DBUS_INT64_PRINTF_MODIFIER, [$dbusint64_printf_modifier], [Define to printf modifier for 64 bit integer type])
|
||||||
|
fi
|
||||||
AC_MSG_RESULT($DBUS_INT64_TYPE)
|
AC_MSG_RESULT($DBUS_INT64_TYPE)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -1089,12 +1128,6 @@ if test "x$GCC" = "xyes"; then
|
||||||
CFLAGS="$CFLAGS -Wno-pointer-sign"
|
CFLAGS="$CFLAGS -Wno-pointer-sign"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
|
||||||
|
|
||||||
# http://bugs.freedesktop.org/show_bug.cgi?id=19195
|
|
||||||
case " $CFLAGS " in
|
|
||||||
*[\ \ ]-Wno-format[\ \ ]*) ;;
|
|
||||||
*) CFLAGS="$CFLAGS -Wno-format" ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# This one is special - it's not a warning override.
|
# This one is special - it's not a warning override.
|
||||||
|
|
|
||||||
|
|
@ -2434,7 +2434,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending)
|
||||||
goto recheck_status;
|
goto recheck_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
_dbus_verbose ("dbus_connection_send_with_reply_and_block(): Waited %ld milliseconds and got no reply\n",
|
_dbus_verbose ("dbus_connection_send_with_reply_and_block(): Waited %d milliseconds and got no reply\n",
|
||||||
elapsed_milliseconds);
|
elapsed_milliseconds);
|
||||||
|
|
||||||
_dbus_assert (!_dbus_pending_call_get_completed_unlocked (pending));
|
_dbus_assert (!_dbus_pending_call_get_completed_unlocked (pending));
|
||||||
|
|
|
||||||
|
|
@ -519,13 +519,13 @@ _dbus_credentials_to_string_append (DBusCredentials *credentials,
|
||||||
join = FALSE;
|
join = FALSE;
|
||||||
if (credentials->unix_uid != DBUS_UID_UNSET)
|
if (credentials->unix_uid != DBUS_UID_UNSET)
|
||||||
{
|
{
|
||||||
if (!_dbus_string_append_printf (string, "uid=%d", credentials->unix_uid))
|
if (!_dbus_string_append_printf (string, "uid=%d", (int) credentials->unix_uid))
|
||||||
goto oom;
|
goto oom;
|
||||||
join = TRUE;
|
join = TRUE;
|
||||||
}
|
}
|
||||||
if (credentials->unix_pid != DBUS_PID_UNSET)
|
if (credentials->unix_pid != DBUS_PID_UNSET)
|
||||||
{
|
{
|
||||||
if (!_dbus_string_append_printf (string, "%spid=%d", join ? " " : "", credentials->unix_pid))
|
if (!_dbus_string_append_printf (string, "%spid=%d", join ? " " : "", (int) credentials->unix_pid))
|
||||||
goto oom;
|
goto oom;
|
||||||
join = TRUE;
|
join = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1386,15 +1386,9 @@ _dbus_verbose_bytes (const unsigned char *data,
|
||||||
if (i > 7 &&
|
if (i > 7 &&
|
||||||
_DBUS_ALIGN_ADDRESS (&data[i], 8) == &data[i])
|
_DBUS_ALIGN_ADDRESS (&data[i], 8) == &data[i])
|
||||||
{
|
{
|
||||||
#ifdef DBUS_HAVE_INT64
|
#ifdef DBUS_INT64_PRINTF_MODIFIER
|
||||||
/* I think I probably mean "GNU libc printf" and not "GNUC"
|
_dbus_verbose (" u64: 0x%" DBUS_INT64_PRINTF_MODIFIER "x",
|
||||||
* but we'll wait until someone complains. If you hit this,
|
|
||||||
* just turn off verbose mode as a workaround.
|
|
||||||
*/
|
|
||||||
#if __GNUC__
|
|
||||||
_dbus_verbose (" u64: 0x%llx",
|
|
||||||
*(dbus_uint64_t*)&data[i-8]);
|
*(dbus_uint64_t*)&data[i-8]);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
_dbus_verbose (" dbl: %g",
|
_dbus_verbose (" dbl: %g",
|
||||||
*(double*)&data[i-8]);
|
*(double*)&data[i-8]);
|
||||||
|
|
|
||||||
|
|
@ -2651,8 +2651,8 @@ double_read_value (TestTypeNode *node,
|
||||||
|
|
||||||
if (!_DBUS_DOUBLES_BITWISE_EQUAL (v, expected))
|
if (!_DBUS_DOUBLES_BITWISE_EQUAL (v, expected))
|
||||||
{
|
{
|
||||||
#ifdef DBUS_HAVE_INT64
|
#ifdef DBUS_INT64_PRINTF_MODIFIER
|
||||||
_dbus_warn ("Expected double %g got %g\n bits = 0x%llx vs.\n bits = 0x%llx)\n",
|
_dbus_warn ("Expected double %g got %g\n bits = 0x%" DBUS_INT64_PRINTF_MODIFIER "x vs.\n bits = 0x%" DBUS_INT64_PRINTF_MODIFIER "x)\n",
|
||||||
expected, v,
|
expected, v,
|
||||||
*(dbus_uint64_t*)(char*)&expected,
|
*(dbus_uint64_t*)(char*)&expected,
|
||||||
*(dbus_uint64_t*)(char*)&v);
|
*(dbus_uint64_t*)(char*)&v);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "dbus-print-message.h"
|
#include "dbus-print-message.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
type_to_name (int message_type)
|
type_to_name (int message_type)
|
||||||
|
|
@ -225,7 +226,9 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
|
||||||
{
|
{
|
||||||
dbus_int64_t val;
|
dbus_int64_t val;
|
||||||
dbus_message_iter_get_basic (iter, &val);
|
dbus_message_iter_get_basic (iter, &val);
|
||||||
printf ("int64 %lld\n", val);
|
#ifdef DBUS_INT64_PRINTF_MODIFIER
|
||||||
|
printf ("int64 %" DBUS_INT64_PRINTF_MODIFIER "d\n", val);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +236,9 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
|
||||||
{
|
{
|
||||||
dbus_uint64_t val;
|
dbus_uint64_t val;
|
||||||
dbus_message_iter_get_basic (iter, &val);
|
dbus_message_iter_get_basic (iter, &val);
|
||||||
printf ("uint64 %llu\n", val);
|
#ifdef DBUS_INT64_PRINTF_MODIFIER
|
||||||
|
printf ("uint64 %" DBUS_INT64_PRINTF_MODIFIER "u\n", val);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue