multi-vkd support patch for review
Jonas Trollvik
jontro at gmail.com
Sun Jan 28 11:13:44 PST 2007
++i returns the new value of i and i++ returns i before being
incremented. See it as a function in that matter.
//Jonas
On 1/28/07, C.Turner <c.turner at 199technologies.org> wrote:
On Sun, 28 Jan 2007 18:08:58 +0100
"Simon 'corecode' Schubert" <corecode at fs.ei.tum.de> wrote:
> Thomas E. Spanjaard wrote:
> > Sepherosa Ziehau wrote:
> >> On 1/28/07, Thomas E. Spanjaard <tgen at netphreax.net> wrote:
> >>> C.Turner wrote:
> >>> > + if ( vkdFileNum < VKD_MAX )
> >>> > + vkdFile[vkdFileNum++] = optarg;
> >>> Why not if (vkdFileNum < VKD_MAX) { vkdFile[vkdFileNum] = optarg;
> >>> vkdFileNum++; }; ? Because now it appears '16' is a valid number,
> >>> where
> >> Why '16'(VKD_MAX) will be a valid number in his patch?
> > if (15 < 16) { vkdFile[(15++ = 16)] = optarg; }
>
> heh, no :)
>
> % cat<<EOF>d.c
> main(){int i=0;printf("%d\n", i++);}
> EOF
> % cc d.c
> % ./a.out
> 0
> %
>
> cheers
> simon
>
yeah.. should have written a test.. *doh*. the C book I referred to (in
*only* 24 hours!!) says '++' is higher in the ops than '=' .. blah. Too
bad the 'standard' costs $$
I think the worry was that = happens after ++ and the [] deref..
anyhoo, your right should be safe (and time to get another book)
$ cat assign-incr.c
main () {
int x[2]= {-1,-1};
int i = 0;
x[i++] = i;
printf("%d, %d\n", x[0], x[1]);
return i;
}
$ cc assign-incr.c
$ ./a.out
0, -1
$ echo $?
1
$
More information about the Submit
mailing list