mirror of
https://salsa.debian.org/ha-team/libqb
synced 2026-08-09 05:09:58 +00:00
LOG: fix the printing of %p in the blackbox
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
1e81530332
commit
9956fe29ff
10
configure.ac
10
configure.ac
@ -125,10 +125,12 @@ fi
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
|
||||
AC_CHECK_HEADERS([arpa/inet.h link.h fcntl.h inttypes.h limits.h netinet/in.h stdint.h \
|
||||
dlfcn.h time.h sys/time.h stdlib.h string.h strings.h sys/types.h sys/stat.h \
|
||||
sys/param.h sys/socket.h sys/time.h sys/poll.h sys/epoll.h sys/uio.h sys/event.h \
|
||||
sys/sockio.h sys/un.h sys/resource.h syslog.h errno.h unistd.h sys/mman.h \
|
||||
AC_CHECK_HEADERS([arpa/inet.h link.h fcntl.h inttypes.h limits.h netinet/in.h \
|
||||
stdint.h stddef.h stdlib.h string.h strings.h \
|
||||
dlfcn.h time.h sys/time.h sys/types.h sys/stat.h \
|
||||
sys/param.h sys/socket.h sys/time.h sys/poll.h sys/epoll.h \
|
||||
sys/uio.h sys/event.h sys/sockio.h sys/un.h sys/resource.h \
|
||||
syslog.h errno.h unistd.h sys/mman.h \
|
||||
sys/sem.h sys/ipc.h sys/msg.h netdb.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
|
||||
@ -41,6 +41,10 @@
|
||||
#include <stdint.h>
|
||||
#endif /* HAVE_STDINT_H */
|
||||
|
||||
#ifdef HAVE_STDDEF_H
|
||||
#include <stddef.h>
|
||||
#endif /* HAVE_STDDEF_H */
|
||||
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
@ -513,10 +513,9 @@ reprocess:
|
||||
}
|
||||
case 'p':
|
||||
{
|
||||
void *arg_pointer;
|
||||
arg_pointer = va_arg(ap, void *);
|
||||
memcpy (&serialize[location], &arg_pointer, sizeof (void *));
|
||||
location += sizeof (arg_pointer);
|
||||
ptrdiff_t arg_pointer = va_arg(ap, ptrdiff_t);
|
||||
memcpy(&serialize[location], &arg_pointer, sizeof(ptrdiff_t));
|
||||
location += sizeof(ptrdiff_t);
|
||||
break;
|
||||
}
|
||||
case '%':
|
||||
@ -698,11 +697,14 @@ reprocess:
|
||||
}
|
||||
case 'p':
|
||||
{
|
||||
ptrdiff_t pt;
|
||||
memcpy(&pt, &buf[data_pos],
|
||||
sizeof(ptrdiff_t));
|
||||
fmt[fmt_pos++] = *format;
|
||||
fmt[fmt_pos++] = '\0';
|
||||
location += snprintf(&string[location],
|
||||
str_len - location,
|
||||
fmt, &buf[data_pos]);
|
||||
fmt, pt);
|
||||
data_pos += sizeof(void*);
|
||||
format++;
|
||||
break;
|
||||
|
||||
@ -49,9 +49,15 @@ format_this(char *out, const char *fmt, ...)
|
||||
START_TEST(test_va_serialize)
|
||||
{
|
||||
char buf[QB_LOG_MAX_LEN];
|
||||
char cmp_buf[QB_LOG_MAX_LEN];
|
||||
|
||||
format_this(buf, "one line");
|
||||
ck_assert_str_eq(buf, "one line");
|
||||
|
||||
format_this(buf, "p1:%p, p2:%p", format_this, buf);
|
||||
snprintf(cmp_buf, QB_LOG_MAX_LEN, "p1:%p, p2:%p", format_this, buf);
|
||||
ck_assert_str_eq(buf, cmp_buf);
|
||||
|
||||
format_this(buf, "s1:%s, s2:%s", "Yes", "Never");
|
||||
ck_assert_str_eq(buf, "s1:Yes, s2:Never");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user