Thread (4 messages) flat view 4 messages, 2 authors, 2016-06-15

Re: [PATCH] Fix a warning (on cygwin) to allow -Werror

From: Ramsay Jones <hidden>
Date: 2016-06-15 22:45:14

Johannes Sixt wrote:
Ramsay Jones schrieb:
quoted
Also, I noticed that git_ntohl() is still defined in compat/mingw.h; is this
still required?  It's not a problem, just curious! (I don't have mingw
installed, so I can't test myself)
Yes, it's still needed. The reason is that on Windows ntohl() returns
'unsigned long', and then gcc warns about

sha1_file.c:700: warning: unsigned int format, u_long arg (arg 3)

git_ntohl() is the workaround.
OK, Thanks.

Ah, yes, everything works on cygwin and Linux because:

                             Linux           Cygwin
    ntohl() returns:         uint32_t        uint32_t
    uint32_t typedef-ed as:  unsigned int    unsigned long
    PRIu32 #define-d as:     "u"             "lu"

So, I suspect (IOW I am guessing that) mingw must have:

    ntohl() returns:         unsigned long (well u_long anyway)
    uint32_t typedef-ed as:  unsigned int
    PRIu32 #define-d ad:     "u"

(I've just noticed that you are not #include-ing inttypes.h, so you are
relying on the PRIu32 defined in git-compat-util.h)

If the above is true, then well, ... Bummer ;-)

I suppose a (very) slight improvement would be to change the return type
of your git_ntohl() wrapper to uint32_t. (But we are talking very slight ;-)

ATB,

Ramsay Jones
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help