Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: [ rockbox-Patches-699202 ] Custom Recording Filenames
From: Greg Haerr (greg_at_censoft.com)
Date: 2003-03-08


> You have a bit of code: *fmtPtr++ which perhaps should be *(fmtPtr++) as *
> takes precedece over ++, which I think is probably not what you want!

Actually, *fmtPtr++ and *(fmtPtr++) will always generate
exactly the same code, since the pointer is post-incremented,
and the original value used regardless of the parenthesis. If
you want to increment first, then dereference, use *++fmtPtr.

> You
> want to increment the pointer, then dereference it, whereas the code is
> trying to dereference then increment the contents!

The real cause of the compiler warning in this case is that
the order of evaluation of function arguments is not
defined by the C standard: the following code snippet
needs to be rewritten:

snprintf(tmpBuf, sizeof(tmpBuf), "%%%c%c", *(fmtPtr-1), *fmtPtr++);

This is because the value of fmtPtr is undefined for the first usage,
since it may or may not have been autoincremented in the
second use in the parameter list.

Regards,

Greg



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa