patchlwIP - A Lightweight TCP/IP stack - Patches: patch #5067, Fix err_to_errno() macro for...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #5067: Fix err_to_errno() macro for sockets API

Submitter:  None
Submitted:  Mon 01 May 2006 10:24:11 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  goldsimon Originator Email:  -email is unavailable-
Open/Closed:  Closed Planned Release:  None

Jump to the original submission

Wed 21 Mar 2007 09:14:59 PM UTC, comment #10: 

fix this bug by casting to (unsigned).
-> closed

Simon Goldschmidt <goldsimon>
Group administrator
Wed 21 Mar 2007 01:14:51 PM UTC, comment #9: 

Yes, go ahead - sorry for the delay, must have missed this question somehow.

Kieran Mansley <kieranm>
Group Member
Fri 09 Mar 2007 11:02:41 AM UTC, comment #8: 

I'll check it in and close this patch if it's OK for you, Kieran

Simon Goldschmidt <goldsimon>
Group administrator
Fri 09 Mar 2007 10:39:51 AM UTC, comment #7: 


> this would be the first reference to the size_t type in the whole stack...

ok, let's use `unsigned' instead. I don't think it makes any difference in this case:

 ((unsigned)(-(err)) < ERR_TO_ERRNO_TABLE_SIZE ?

the warning will disappear.

Dmitry Potapov <dpotapov>
Fri 09 Mar 2007 10:17:42 AM UTC, comment #6: 

Ok, I don't have such a compiler, I only was cautious because this would be the first reference to the size_t type in the whole stack...
If we would use it here, we also should use it with the complete socket layer, as other OSes (I'd still like to see a socket standard definition) use size_t for length information.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 09 Mar 2007 09:57:52 AM UTC, comment #5: 

Simon,
when you say most compiler don't have size_t, do you mean C compilers or some other languages? I am asking, because the C standard clearly mandates  this type:

===
6.5.3.4 The sizeof operator
  ...
4 The value of the result is implementation-defined, and its type (an unsigned integer type)
  is size_t, defined in <stddef.h> (and other headers).
====
7.17 Common definitions <stddef.h>
 ...
       size_t
which is the unsigned integer type of the result of the sizeof operator; and
===
and it is used in prototypes of many functions -- fread, fwrite, malloc, calloc, strlen, just to name a few.

You just need to include stddef.h to use this type.

But if your compiler is so damn broken that it does not have size_t, there is a simple workaround -- add to arch/cc.h for your port:
typedef unsigned size_t;


Dmitry Potapov <dpotapov>
Fri 09 Mar 2007 08:56:10 AM UTC, comment #4: 

Remember that most systems/compilers don't have the size_t type.

Simon Goldschmidt <goldsimon>
Group administrator
Tue 06 Mar 2007 09:20:22 AM UTC, comment #3: 

Accordingly to CVS, the original patch was applyed three weeks ago:
date: 2006-02-13 08:14:11 +0000;  author: christiaans;  state: Exp;  lines: +5 -2
Patch from Curt McDowell fixes err_to_errno macro.

BTW, I believe that it would be suffient to write:

 ((size_t)(-(err)) < ERR_TO_ERRNO_TABLE_SIZE ?

because even if err happens to be positive then
((size_t)(-(err)) will be larger than ERR_TO_ERRNO_TABLE_SIZE.
So, one comparision less, and you have smaller footprint.

I used 'size_t' above (not 'u8_t') because ERR_TO_ERRNO_TABLE_SIZE is 'size_t', so when you use `size_t', you have smaller code than with 'u8_t'

Dmitry Potapov <dpotapov>
Tue 06 Mar 2007 08:18:20 AM UTC, comment #2: 

Isn't this one already applied? I have another patch, though:

Currently, signed and unsigned are compared after the &&:
  (-(err) >= 0 && -(err) < ERR_TO_ERRNO_TABLE_SIZE ? \

since we know err is negative, casting -err to u8_t can do no harm and gets rid of the warning:
  (-(err) >= 0 && (u8_t)(-(err)) < ERR_TO_ERRNO_TABLE_SIZE ? \

Simon Goldschmidt <goldsimon>
Group administrator
Mon 19 Feb 2007 11:10:47 AM UTC, comment #1: 

This looks like a good change to make.  I'll apply if no one objects

Kieran Mansley <kieranm>
Group Member
Mon 01 May 2006 10:24:11 PM UTC, original submission:  

See attached patch.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #9872:  lwip-errno-p added by None (646B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dpotapov (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by kieranm (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-03-21 goldsimon StatusNone Done
        Open/ClosedOpen Closed
    2007-03-21 kieranm Assigned tokieranm goldsimon
    2007-02-19 kieranm Assigned toNone kieranm
    2006-05-01 None Attached File- Added lwip-errno-p, #9872

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code