linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Linphone-developers] use proper printf rather than ugly cast in cor


From: Mike Frysinger
Subject: Re: [Linphone-developers] use proper printf rather than ugly cast in coreapi/linphonecore.c
Date: Wed, 2 Jan 2008 13:54:38 -0500

On Jan 2, 2008 1:48 PM, strk <address@hidden> wrote:
> On Wed, Jan 02, 2008 at 01:40:32PM -0500, Mike Frysinger wrote:
> > it looks like in order to get rid of a warning, someone did:
> > snprintf(clen,sizeof(clen),"%u",(unsigned int)strlen(dtmf_body));
> > that's just silly ... strlen returns a size_t, not an unsigned int.
> > so just use a proper printf format string and everything is fine:
> > snprintf(clen,sizeof(clen),"%zi",strlen(dtmf_body));
>
> I belive %z only works with the GNU libc.

that is hardly correct.  any POSIX compliant system respects the z
modifier.  please refer to the documentation:
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html

> What's wrong about casting size_t to unsigned int btw ?

ignoring the fact it's just butt-ass ugly, there is no guarantee that
sizeof(size_t) == sizeof(unsigned int) (and in fact is wrong on most
64bit operating systems).  whoever wrote the patch probably just
assumed that because they were running on a 32bit system.  but that
setup/assumption has screwed up a lot of code out there.
-mike




reply via email to

[Prev in Thread] Current Thread [Next in Thread]