Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix 900+ acceptance tests on Windows #1853

Merged
merged 2 commits into from

3 participants

@kacfengine
Owner
commit e3c783495923f6829b77f7e43fe7e41385f1e6c2
Author: Kristian Amlie 
Date:   Fri Jul 18 14:46:51 2014

    Use %jd and %ju instead of PRIdMAX and PRIuMAX.
    
    The problem is that on Windows PRI[du]MAX expands to a
    Windows-specific printf flag, but we are using printf wrappers, which
    do not understand that flag. The 'j' flag on the other hand, is not
    supported by Windows, but *is* supported by our wrapper, so it's safe
    to use.
    
    One notable exception from in the commit is a scanf which uses
    PRIdMAX. scanf is not covered by our wrappers at the moment, and has
    no replacement, so we need to leave that as it is. sprintf is not
    covered either, but can (and should) be replaced with snprintf.

commit 26b224c7598bd19237fbc1be6844416f50266658
Author: Kristian Amlie 
Date:   Fri Jul 18 14:44:28 2014

    Disable printf format warnings on Windows.
    
    Our wrapper supports more flags than vanilla Windows version, so they
    are false positives.
kacfengine added some commits
@kacfengine kacfengine Disable printf format warnings on Windows.
Our wrapper supports more flags than vanilla Windows version, so they
are false positives.
26b224c
@kacfengine kacfengine Use %jd and %ju instead of PRIdMAX and PRIuMAX.
The problem is that on Windows PRI[du]MAX expands to a
Windows-specific printf flag, but we are using printf wrappers, which
do not understand that flag. The 'j' flag on the other hand, is not
supported by Windows, but *is* supported by our wrapper, so it's safe
to use.

One notable exception from in the commit is a scanf which uses
PRIdMAX. scanf is not covered by our wrappers at the moment, and has
no replacement, so we need to leave that as it is. sprintf is not
covered either, but can (and should) be replaced with snprintf.
e3c7834
@ediosyncratic
Collaborator

Obvious hazard: are there any other platforms on which PRI[du]MAX is needed because we're using the native printf-family ?

@kacfengine
Owner

Obvious hazard: are there any other platforms on which PRI[du]MAX is needed because we're using the native printf-family ?

No. According to @jimis (correct me if I'm wrong here), all our platforms use wrappers except Linux. And the wrappers support %jd.

@ediosyncratic
Collaborator

OK, good that the obvious hazard is a non-issue.

Testing failed due to memory running out, on RedHat. I'll run with the theory that this is a build-system failure rather than a problem with your change.

@ediosyncratic ediosyncratic merged commit be8cd4f into from
@jimis
Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2014
  1. @kacfengine

    Disable printf format warnings on Windows.

    kacfengine authored
    Our wrapper supports more flags than vanilla Windows version, so they
    are false positives.
  2. @kacfengine

    Use %jd and %ju instead of PRIdMAX and PRIuMAX.

    kacfengine authored
    The problem is that on Windows PRI[du]MAX expands to a
    Windows-specific printf flag, but we are using printf wrappers, which
    do not understand that flag. The 'j' flag on the other hand, is not
    supported by Windows, but *is* supported by our wrapper, so it's safe
    to use.
    
    One notable exception from in the commit is a scanf which uses
    PRIdMAX. scanf is not covered by our wrappers at the moment, and has
    no replacement, so we need to leave that as it is. sprintf is not
    covered either, but can (and should) be replaced with snprintf.
This page is out of date. Refresh to see the latest.
View
12 configure.ac
@@ -171,6 +171,16 @@ AS_IF([test x"$enable_fhs" = xyes], [
AC_SUBST(projlibdir)
dnl ######################################################################
+dnl Platform specific compiler flags.
+dnl ######################################################################
+
+AS_CASE([${target_os}],
+ [mingw*],
+ # Disable printf format warnings, because our wrapper supports more
+ # flags than vanilla Windows version, so they are false positives.
+ [CFLAGS="$CFLAGS -Wno-format"])
+
+dnl ######################################################################
dnl Enable debugging
dnl ######################################################################
@@ -855,7 +865,7 @@ AC_EGREP_CPP([primacros_found],
],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
- AC_MSG_RESULT(Unable to find out how to print intmax_t/uintmax_t types)])
+ AC_MSG_RESULT(Unable to find out how to scan intmax_t/uintmax_t types)])
HW_FUNC_VSNPRINTF
HW_FUNC_SNPRINTF
View
2  libpromises/enterprise_stubs.c
@@ -120,7 +120,7 @@ ENTERPRISE_VOID_FUNC_2ARG_DEFINE_STUB(void, LogTotalCompliance, const char *, ve
}
else
{
- fprintf(fout, "%" PRIdMAX ",%" PRIdMAX ": %s\n", (intmax_t)CFSTARTTIME, (intmax_t)time(NULL), string);
+ fprintf(fout, "%jd,%jd: %s\n", (intmax_t)CFSTARTTIME, (intmax_t)time(NULL), string);
fclose(fout);
}
}
View
2  libpromises/generic_agent.c
@@ -1304,7 +1304,7 @@ void WritePID(char *filename)
return;
}
- fprintf(fp, "%" PRIuMAX "\n", (uintmax_t)getpid());
+ fprintf(fp, "%ju\n", (uintmax_t)getpid());
fclose(fp);
}
View
2  libpromises/pipes_unix.c
@@ -535,7 +535,7 @@ static int cf_pwait(pid_t pid)
{
int status;
- Log(LOG_LEVEL_DEBUG, "cf_pwait - Waiting for process %" PRIdMAX, (intmax_t)pid);
+ Log(LOG_LEVEL_DEBUG, "cf_pwait - Waiting for process %jd", (intmax_t)pid);
while (waitpid(pid, &status, 0) < 0)
{
View
2  libpromises/storage_tools.c
@@ -93,7 +93,7 @@ off_t GetDiskUsage(char *file, CfSize type)
capacity = (double) (avail) / (double) (avail + used) * 100;
- Log(LOG_LEVEL_DEBUG, "GetDiskUsage(%s) = %" PRIdMAX "/%" PRIdMAX, file, (intmax_t) avail, (intmax_t) capacity);
+ Log(LOG_LEVEL_DEBUG, "GetDiskUsage(%s) = %jd/%jd", file, (intmax_t) avail, (intmax_t) capacity);
if (type == CF_SIZE_ABS)
{
View
6 libpromises/unix.c
@@ -43,7 +43,7 @@ void ProcessSignalTerminate(pid_t pid)
if(kill(pid, SIGINT) == -1)
{
- Log(LOG_LEVEL_ERR, "Could not send SIGINT to pid '%" PRIdMAX "'. (kill: %s)",
+ Log(LOG_LEVEL_ERR, "Could not send SIGINT to pid '%jd'. (kill: %s)",
(intmax_t)pid, GetErrorStr());
}
@@ -52,7 +52,7 @@ void ProcessSignalTerminate(pid_t pid)
if(kill(pid, SIGTERM) == -1)
{
- Log(LOG_LEVEL_ERR, "Could not send SIGTERM to pid '%" PRIdMAX "'. (kill: %s)",
+ Log(LOG_LEVEL_ERR, "Could not send SIGTERM to pid '%jd'. (kill: %s)",
(intmax_t)pid, GetErrorStr());
}
@@ -61,7 +61,7 @@ void ProcessSignalTerminate(pid_t pid)
if(kill(pid, SIGKILL) == -1)
{
- Log(LOG_LEVEL_ERR, "Could not send SIGKILL to pid '%" PRIdMAX "'. (kill: %s)",
+ Log(LOG_LEVEL_ERR, "Could not send SIGKILL to pid '%jd'. (kill: %s)",
(intmax_t)pid, GetErrorStr());
}
Something went wrong with that request. Please try again.