Rockbox mail archive
Subject: Re: [ rockbox-Patches-699202 ] Custom Recording Filenames
From: Greg Haerr (greg_at_censoft.com)
> 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.
> 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.
Page was last modified "Jan 10 2012" The Rockbox Crew