Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Another strange linux kernel change

Reply
Thread Tools

Another strange linux kernel change

 
 
Man-wai Chang to The Door (24000bps)
Guest
Posts: n/a
 
      01-29-2010

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

http://www.kernel.org/diff/diffview....2.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_...sub_addressesa
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      01-29-2010
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
 
Reply With Quote
 
 
 
 
Vladimir Jovic
Guest
Posts: n/a
 
      01-29-2010
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.
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      01-29-2010
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?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
Daniel Giaimo
Guest
Posts: n/a
 
      01-29-2010
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....2.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

 
Reply With Quote
 
Vladimir Jovic
Guest
Posts: n/a
 
      01-29-2010
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
 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      01-29-2010
Vladimir Jovic <(E-Mail Removed)> writes:
>>>> i++ --> ++i, on a separate line! Does it matter?
>>>No.

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


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

 
Reply With Quote
 
Man-wai Chang to The Door (24000bps)
Guest
Posts: n/a
 
      01-30-2010
> 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_...sub_addressesa
 
Reply With Quote
 
Man-wai Chang to The Door (24000bps)
Guest
Posts: n/a
 
      01-30-2010
> 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_...sub_addressesa
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      01-30-2010
On Jan 30, 10:38 am, "Man-wai Chang to The Door (24000bps)"
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel#autoload ignores custom monkey patched Kernel#require Lars Gierth Ruby 6 03-20-2010 10:35 PM
Strange behavior of Kernel::system Phil Ruby 1 03-31-2008 07:09 AM
Why "Kernel.puts" and not "Kernel.put"? shadytrees@gmail.com Ruby 3 04-08-2006 01:42 PM
kernel hangs after "UNCOMPRESSING KERNEL OK BOOTING KERNEL" yogesh C Programming 3 02-12-2006 11:19 AM
How to change which kernel in Red Hat Dibble Dobble Computer Support 2 08-20-2005 11:46 AM



Advertisments