From c2849fc4b1a4618f2d81ef2597d7e40d7b2e048c Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sat, 17 Nov 2007 19:16:53 +0100 Subject: [PATCH] Fix ntohl() related warnings about printf formatting On Windows, ntohl() returns unsinged long. On Unix it returns uint32_t. This makes choosing a suitable printf format string hard. This commit introduces a mingw specific helper function git_ntohl() that casts to unsigned int before returning. This makes gcc's printf format check happy. It should be safe because we expect ntohl to use 32-bit numbers. Signed-off-by: Steffen Prohaska --- git-compat-util.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/git-compat-util.h b/git-compat-util.h index b76f94fc05..74412331d8 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -594,6 +594,10 @@ static inline int mingw_fcntl(int fd, int cmd, long arg) { return cmd == F_GETFD || cmd == F_SETFD ? 0 : (errno = EINVAL, -1); } #define fcntl mingw_fcntl +static inline unsigned int git_ntohl(unsigned int x) +{ return (unsigned int)ntohl(x); } +#define ntohl git_ntohl + #endif /* __MINGW32__ */ #endif -- 2.11.4.GIT