Another strange linux kernel change

  • Thread starter Man-wai Chang to The Door (24000bps)
  • Start date
M

Man-wai Chang to The Door (24000bps)

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

http://www.kernel.org/diff/diffview.cgi?file=/pub/linux/kernel/v2.6/incr/patch-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
 
V

Victor Bazarov

Man-wai Chang to The Door (24000bps) said:
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
 
V

Vladimir Jovic

Man-wai Chang to The Door (24000bps) said:
i++ --> ++i, on a separate line! Does it matter?

No.

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

Victor Bazarov

Vladimir said:
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?

V
 
V

Vladimir Jovic

Victor said:
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 ;)
 
S

Stefan Ram

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

The OP said »on a separate line«, so that should be:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
j =
i++
;

versus

j =
++i
;

(Of course, this is irrelevant, but the question was put in
this way.)
 
M

Man-wai Chang to The Door (24000bps)

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
ä¸å€Ÿè²¸! ä¸è©é¨™! ä¸æ´äº¤! ä¸æ‰“交! ä¸æ‰“劫! ä¸è‡ªæ®º! è«‹è€ƒæ…®ç¶œæ´ (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa
 
M

Man-wai Chang to The Door (24000bps)

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
ä¸å€Ÿè²¸! ä¸è©é¨™! ä¸æ´äº¤! ä¸æ‰“交! ä¸æ‰“劫! ä¸è‡ªæ®º! è«‹è€ƒæ…®ç¶œæ´ (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa
 
J

James Kanze

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.)
 
D

Daniel Giaimo

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.
 
M

Man-wai Chang to The Door (24000bps)

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
ä¸å€Ÿè²¸! ä¸è©é¨™! ä¸æ´äº¤! ä¸æ‰“交! ä¸æ‰“劫! ä¸è‡ªæ®º! è«‹è€ƒæ…®ç¶œæ´ (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa
 
T

tonydee

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
 
M

Man-wai Chang to The Door (24000bps)

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
ä¸å€Ÿè²¸! ä¸è©é¨™! ä¸æ´äº¤! ä¸æ‰“交! ä¸æ‰“劫! ä¸è‡ªæ®º! è«‹è€ƒæ…®ç¶œæ´ (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top