Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Another strange linux kernel change

1 view
Skip to first unread message

Man-wai Chang to The Door (24000bps)

unread,
Jan 29, 2010, 8:45:58 AM1/29/10
to

i++ --> ++i, on a separate line! Does it matter?

http://www.kernel.org/diff/diffview.cgi?file=%2Fpub%2Flinux%2Fkernel%2Fv2.6%2Fincr%2Fpatch-2.6.32.6-7.bz2;z=69


--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.6
^ ^ 21:44:01 up 2 days 7:24 2 users load average: 1.38 1.19 1.11
不借貸! 不詐騙! 不援交! 不打交! 不打劫! 不自殺! 請考慮綜援 (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa

Vladimir Jovic

unread,
Jan 29, 2010, 9:20:08 AM1/29/10
to
Man-wai Chang to The Door (24000bps) wrote:
>
> i++ --> ++i, on a separate line! Does it matter?
>

No.

If it was like this:
j = ++i + i ++;
then it would matter.

Victor Bazarov

unread,
Jan 29, 2010, 9:19:39 AM1/29/10
to
Man-wai Chang to The Door (24000bps) wrote:
>
> i++ --> ++i, on a separate line! Does it matter?
>

Do you mean to tell us that you don't know the difference between
pre-increment and post-increment?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Victor Bazarov

unread,
Jan 29, 2010, 9:23:16 AM1/29/10
to

Huh?

Are you saying that

j = i++;

and

j = ++i;

have the same effect?

Daniel Giaimo

unread,
Jan 29, 2010, 9:43:22 AM1/29/10
to
On 1/29/2010 8:45 AM, Man-wai Chang to The Door (24000bps) wrote:
>
> i++ --> ++i, on a separate line! Does it matter?
>
> http://www.kernel.org/diff/diffview.cgi?file=%2Fpub%2Flinux%2Fkernel%2Fv2.6%2Fincr%2Fpatch-2.6.32.6-7.bz2;z=69

i++ increments i and returns the old value. ++i increments i and
returns the new value. So, for example, if i were 4 to begin with,
then before the change the code would cause i to become 5 and j to
become 4, and after the change the code would cause i to become 5
and j to become 5.

--
Dan G

Vladimir Jovic

unread,
Jan 29, 2010, 10:37:52 AM1/29/10
to
Victor Bazarov wrote:
> Vladimir Jovic wrote:
>> Man-wai Chang to The Door (24000bps) wrote:
>>>
>>> i++ --> ++i, on a separate line! Does it matter?
>>>
>>
>> No.
>>
>> If it was like this:
>> j = ++i + i ++;
>> then it would matter.
>
> Huh?
>
> Are you saying that
>
> j = i++;
>
> and
>
> j = ++i;
>
> have the same effect?


Yes, that's what I said (shame on me). Fortunately I do not have to
debug offset by 1 in the j ;)

Message has been deleted

Man-wai Chang to The Door (24000bps)

unread,
Jan 30, 2010, 4:40:58 AM1/30/10
to
> If it was like this:
> j = ++i + i ++;
> then it would matter.

Then that person could submit change to that program again and again and
got paid as usual. :)

1. change from "j=++i" to "j=i++"
2. change from "j=i++" to "j=++i"
3. go to (1)

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!

/( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.7
^ ^ 17:38:01 up 1:44 0 users load average: 1.08 1.02 1.00

Man-wai Chang to The Door (24000bps)

unread,
Jan 30, 2010, 5:38:17 AM1/30/10
to
> i++ increments i and returns the old value. ++i increments i and
> returns the new value. So, for example, if i were 4 to begin with,
> then before the change the code would cause i to become 5 and j to
> become 4, and after the change the code would cause i to become 5
> and j to become 5.

I understood pre- and post-increment. But that line does not really
affect anything critical.

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!

/( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.7
^ ^ 18:37:01 up 2:43 0 users load average: 1.00 1.00 1.00

James Kanze

unread,
Jan 30, 2010, 7:22:16 AM1/30/10
to
On Jan 30, 10:38 am, "Man-wai Chang to The Door (24000bps)"

<toylet.toy...@gmail.com> wrote:
> > i++ increments i and returns the old value. ++i increments i
> > and returns the new value. So, for example, if i were 4 to
> > begin with, then before the change the code would cause i to
> > become 5 and j to become 4, and after the change the code
> > would cause i to become 5 and j to become 5.

> I understood pre- and post-increment. But that line does not
> really affect anything critical.

Then the correction should be to delete it completely. My
impression is that j *is* being used later, so the change does
change the observable behavior of the code. (If j is not used
later, of course, you can just remove the assignment
completely.)

--
James Kanze

Daniel Giaimo

unread,
Jan 30, 2010, 5:12:33 PM1/30/10
to
On 1/30/2010 5:38 AM, Man-wai Chang to The Door (24000bps) wrote:
>> i++ increments i and returns the old value. ++i increments i and
>> returns the new value. So, for example, if i were 4 to begin with,
>> then before the change the code would cause i to become 5 and j to
>> become 4, and after the change the code would cause i to become 5
>> and j to become 5.
>
> I understood pre- and post-increment. But that line does not really
> affect anything critical.
>

Maybe you know more about the pre-conditions satisfied when this
particular piece of code is run, but from reading just what you posted
j is used on the very next line, so I would assume it matters whether
it starts at i or i+1.

--
Dan G

Man-wai Chang to The Door (24000bps)

unread,
Jan 31, 2010, 7:04:31 AM1/31/10
to
> Maybe you know more about the pre-conditions satisfied when this
> particular piece of code is run, but from reading just what you posted
> j is used on the very next line, so I would assume it matters whether
> it starts at i or i+1.

If that line was critical, it should have caused a kernel error in the
very beginning... :)

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.7

^ ^ 20:04:01 up 1 day 4:10 1 user load average: 1.21 1.11 1.09

tonydee

unread,
Jan 31, 2010, 11:00:52 PM1/31/10
to
On Jan 31, 9:04 pm, "Man-wai Chang to The Door (24000bps)"

<toylet.toy...@gmail.com> wrote:
> If that line was critical, it should have caused a kernel error in the
> very beginning... :)

Ummmm... if your idea of quality control is that anything that doesn't
immediately crash your kernel can't be too bad, then please don't
submit any code.... ;-P. - Tony

Man-wai Chang to The Door (24000bps)

unread,
Feb 1, 2010, 3:45:35 AM2/1/10
to
> Ummmm... if your idea of quality control is that anything that doesn't
> immediately crash your kernel can't be too bad, then please don't
> submit any code.... ;-P. - Tony

Not if that programmer did something wrong in the very beginning! :)

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.7

^ ^ 16:45:01 up 2 days 51 min 1 user load average: 1.05 1.09 1.08

Jorgen Grahn

unread,
Feb 2, 2010, 7:26:08 PM2/2/10
to
On Fri, 2010-01-29, Man-wai Chang to The Door (24000bps) wrote:
>
> i++ --> ++i, on a separate line! Does it matter?

Last time I checked, Linux was written in C. This is comp.lang.c++.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

0 new messages