This will guarantee the macro constant is always defined, which allows us to remove an equivalent code branch, which in normal conditions is dead code. As a side effect this unconfuses static code analyzers like cppcheck or coverity.
@@ -93,6 +93,7 @@ DPKG_CHECK_DECL([makedev], [sys/types.h])
DPKG_CHECK_DECL([WCOREDUMP], [sys/wait.h])
DPKG_CHECK_DECL([TIOCNOTTY], [sys/ioctl.h])
DPKG_CHECK_DECL([O_NOFOLLOW], [fcntl.h])
+DPKG_CHECK_DECL([P_tmpdir], [stdio.h])
DPKG_CHECK_PROGNAME
DPKG_CHECK_COMPAT_FUNCS([getopt getopt_long obstack_free \
strnlen strndup strerror strsignal asprintf \
@@ -38,6 +38,10 @@ extern "C" {
#define O_NOFOLLOW 0
#endif
+#ifndef HAVE_P_TMPDIR
+#define P_tmpdir "/tmp"
+#endif
+
/*
* Define WCOREDUMP if we don't have it already, coredumps won't be
* detected, though.
@@ -106,12 +106,8 @@ path_make_temp_template(const char *suffix)
char *template;
tmpdir = getenv("TMPDIR");
-#ifdef P_tmpdir
if (!tmpdir)
tmpdir = P_tmpdir;
-#endif
- if (!tmpdir)
- tmpdir = "/tmp";
m_asprintf(&template, "%s/%s.XXXXXX", tmpdir, suffix);