[bug #19052] ppp.h version 1.2 has broken Macros GETSORT/LONG

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #19052] ppp.h version 1.2 has broken Macros GETSORT/LONG

Ondrej Lufinka

URL:
  <http://savannah.nongnu.org/bugs/?19052>

                 Summary: ppp.h version 1.2 has broken Macros GETSORT/LONG
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: None
            Submitted on: Tuesday 02/13/2007 at 16:39 UTC
                Category: Contrib
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

#define GETSHORT(s, cp) { \
    (s) = *(cp); (cp)++; (s) << 8; \
                         ^^^^^^^^ useless
    (s) |= *(cp); (cp)++; \
}

Version 1.1 was correct:
#define GETSHORT(s, cp) { \
    (s) = *(cp)++ << 8; \
    (s) |= *(cp)++; \
}

Same for GETLOG, with the resolt, that PPP connections fails
with bad LCP states...




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?19052>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #19052] ppp.h version 1.2 has broken Macros GETSORT/LONG

Ondrej Lufinka

Follow-up Comment #1, bug #19052 (project lwip):

I expect the second line of the macro should contain (s)<<=8;

I think this is attempting to work around a problem which recurs (for me)
many times throughout lwip.
There are many macros which attempt to construct 16- or 32-bit quantities by
taking a number of bytes and shifting them left various amounts.
Unfortunately, in my compiler at least, taking a byte/char and shifting it
left by more than 7 bits is optimised completely away UNLESS the value is
first cast to a u16_t or a u32_t.

Len Chisholm.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?19052>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #19052] ppp.h version 1.2 has broken Macros GETSORT/LONG

Ondrej Lufinka

Follow-up Comment #2, bug #19052 (project lwip):

Fixed this in CVS HEAD, previous fix for #9191 was indeed broken.
Please, test and report back if this case can be closed.


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?19052>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #19052] ppp.h version 1.2 has broken Macros GETSORT/LONG

Ondrej Lufinka

Update of bug #19052 (project lwip):

                  Status:                    None => Fixed                  


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?19052>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #19052] ppp.h version 1.2 has broken Macros GETSORT/LONG

Ondrej Lufinka

Update of bug #19052 (project lwip):

             Open/Closed:                    Open => Closed                


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?19052>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #19052] ppp.h version 1.2 has broken Macros GETSORT/LONG

Ondrej Lufinka

Follow-up Comment #3, bug #19052 (project lwip):

Len writes below:
> Unfortunately, in my compiler at least,
> taking a byte/char and shifting it left
> by more than 7 bits is optimised completely
> away

If that's the Renesas/Mitsubishi NC308 compiler for the M16C and M32C CPU
chips, then add te command line option "-fETI" (Extend (bytes) To Integer) so
as to be (sligtly more) ANSI compliant.

The original reporter of #9191 (bjorn sundman?) was using this compiler.

Those with these problems using OTHER compilers should check their compiler
manuals for options to force correct (ANSI) operation.


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?19052>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel