Another strange linux kernel change

Discussion in 'C++' started by Man-wai Chang to The Door (24000bps), Jan 29, 2010.

  1. 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
    Man-wai Chang to The Door (24000bps), Jan 29, 2010
    #1
    1. Advertising

  2. 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, Jan 29, 2010
    #2
    1. Advertising

  3. 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.
    Vladimir Jovic, Jan 29, 2010
    #3
  4. 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
    Victor Bazarov, Jan 29, 2010
    #4
  5. 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=/pub/linux/kernel/v2.6/incr/patch-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
    Daniel Giaimo, Jan 29, 2010
    #5
  6. 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 ;)
    Vladimir Jovic, Jan 29, 2010
    #6
  7. Man-wai Chang to The Door (24000bps)

    Stefan Ram Guest

    Vladimir Jovic <> 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.)
    Stefan Ram, Jan 29, 2010
    #7
  8. > 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
    Man-wai Chang to The Door (24000bps), Jan 30, 2010
    #8
  9. > 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
    Man-wai Chang to The Door (24000bps), Jan 30, 2010
    #9
  10. Man-wai Chang to The Door (24000bps)

    James Kanze Guest

    On Jan 30, 10: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.


    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
    James Kanze, Jan 30, 2010
    #10
  11. 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
    Daniel Giaimo, Jan 30, 2010
    #11
  12. > 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
    Man-wai Chang to The Door (24000bps), Jan 31, 2010
    #12
  13. Man-wai Chang to The Door (24000bps)

    tonydee Guest

    On Jan 31, 9:04 pm, "Man-wai Chang to The Door (24000bps)"
    <> 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
    tonydee, Feb 1, 2010
    #13
  14. > 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
    Man-wai Chang to The Door (24000bps), Feb 1, 2010
    #14
  15. Man-wai Chang to The Door (24000bps)

    Jorgen Grahn Guest

    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 .
    Jorgen Grahn, Feb 3, 2010
    #15
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Don
    Replies:
    1
    Views:
    5,597
    Victor Bazarov
    Feb 8, 2004
  2. yogesh
    Replies:
    3
    Views:
    586
    Kenny McCormack
    Feb 12, 2006
  3. Replies:
    3
    Views:
    168
  4. Phil
    Replies:
    1
    Views:
    79
  5. Lars Gierth
    Replies:
    6
    Views:
    221
    David Masover
    Mar 20, 2010
Loading...

Share This Page