[systemd-commits] 2 commits - configure.ac src/journal

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Sat Apr 26 05:26:41 PDT 2014


 configure.ac                     |   23 ++++++++++++++++++++---
 src/journal/test-journal-flush.c |    7 +++++--
 2 files changed, 25 insertions(+), 5 deletions(-)

New commits:
commit ae0ceefc2f432bc1068889fcff53d929eca8a3c4
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Apr 24 20:49:15 2014 +0200

    build-sys: add configure switch for -fsanitize=undefined
    
    --enable-undefined-sanitizer mirrors --enable-memory-sanitizer.

diff --git a/configure.ac b/configure.ac
index d40fb38..58bba54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,23 @@ AS_IF([test "x$enable_address_sanitizer" = "xyes"], [
             address_sanitizer_ldflags="-Wc,-fsanitize=address"
       ])
 
+undefined_sanitizer_cflags=
+undefined_sanitizer_cppflags=
+undefined_sanitizer_ldflags=
+AC_ARG_ENABLE(undefined-sanitizer, AS_HELP_STRING([--enable-undefined-sanitizer], [enable -fsanitize=undefined]))
+AS_IF([test "x$enable_undefined_sanitizer" = "xyes"], [
+            CC_CHECK_FLAG_APPEND([with_us_cflags], [CFLAGS], [-fsanitize=undefined])
+            AS_IF([test -z "$with_us_cflags"],
+                  [AC_MSG_ERROR([*** -fsanitize=undefined is not supported])])
+            undefined_sanitizer_cflags="$with_us_cflags -fno-omit-frame-pointer -DVALGRIND=1"
+            undefined_sanitizer_cppflags="-DVALGRIND=1"
+            undefined_sanitizer_ldflags="-Wc,-fsanitize=undefined"
+      ])
+
+sanitizer_cflags="$address_sanitizer_cflags $undefined_sanitizer_cflags"
+sanitizer_cppflags="$address_sanitizer_cppflags $undefined_sanitizer_cppflags"
+sanitizer_ldflags="$address_sanitizer_ldflags $undefined_sanitizer_ldflags"
+
 CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
         -pipe \
         -Wall \
@@ -162,13 +179,13 @@ AS_CASE([$CFLAGS], [*-O[[12345\ ]]*],
         [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
                -flto])],
         [AC_MSG_RESULT([skipping -flto, optimization not enabled])])
-AC_SUBST([OUR_CFLAGS], "$with_cflags $address_sanitizer_cflags")
+AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
 
 AS_CASE([$CFLAGS], [*-O[[12345\ ]]*],
         [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
                -Wp,-D_FORTIFY_SOURCE=2])],
         [AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
-AC_SUBST([OUR_CPPFLAGS], "$with_cppflags $address_sanitizer_cppflags")
+AC_SUBST([OUR_CPPFLAGS], "$with_cppflags $sanitizer_cppflags")
 
 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
         -Wl,--as-needed \
@@ -177,7 +194,7 @@ CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
         -Wl,-z,relro \
         -Wl,-z,now \
         -Wl,-fuse-ld=gold])
-AC_SUBST([OUR_LDFLAGS], "$with_ldflags $address_sanitizer_ldflags")
+AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags")
 
 AC_CHECK_SIZEOF(pid_t)
 AC_CHECK_SIZEOF(uid_t)

commit dfd9cf7f0b257d38f5527989dd9315e767fbe41b
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Apr 25 19:58:21 2014 -0400

    test-journal-flush: avoid predictable names in /var/tmp

diff --git a/src/journal/test-journal-flush.c b/src/journal/test-journal-flush.c
index e61e87a..0ca24e0 100644
--- a/src/journal/test-journal-flush.c
+++ b/src/journal/test-journal-flush.c
@@ -27,13 +27,14 @@
 
 int main(int argc, char *argv[]) {
 
-        char fn[sizeof("/var/tmp/test-journal-flush-")-1 + DECIMAL_STR_MAX(pid_t) + sizeof(".journal")];
+        char dn[] = "/var/tmp/test-journal-flush.XXXXXX", *fn;
         JournalFile *new_journal = NULL;
         sd_journal *j = NULL;
         unsigned n = 0;
         int r;
 
-        sprintf(fn, "/var/tmp/test-journal-flush-%lu.journal", (unsigned long) getpid());
+        assert_se(mkdtemp(dn));
+        fn = strappend(dn, "/test.journal");
 
         r = journal_file_open(fn, O_CREAT|O_RDWR, 0644, false, false, NULL, NULL, NULL, &new_journal);
         assert_se(r >= 0);
@@ -67,5 +68,7 @@ int main(int argc, char *argv[]) {
 
         journal_file_close(new_journal);
 
+        assert_se(rmdir(dn) == 0);
+
         return 0;
 }



More information about the systemd-commits mailing list