lwIP - A Lightweight TCP/IP stack - Patches: patch #7130, mib2.c: remove meaningless const...
You are not allowed to post comments on this tracker with your current authentication level.
patch #7130: mib2.c: remove meaningless const qualifiers
Submitter: | Luca Ceresoli <lucaceresoli> | ||
Submitted: | Tue 23 Mar 2010 04:19:46 PM UTC | ||
Category: | None | Priority: | 5 - Normal |
Status: | Done | Privacy: | Public |
Assigned to: | goldsimon | Open/Closed: | Closed |
Planned Release: | None |
Jump to the original submission
Sat 27 Mar 2010 04:25:47 PM UTC, comment #19: |
Simon Goldschmidt <goldsimon> |
Sat 27 Mar 2010 09:23:34 AM UTC, comment #18: Oh, OK. The const in the cast is unnecessary (and therefore not supported by some compilers, or cdecl?) as it is meaningless because the value of the pointer is copied into the array. Somehow, I didn't get that before ;-)
|
Simon Goldschmidt <goldsimon> |
Fri 26 Mar 2010 05:18:41 PM UTC, comment #17: Sorry for lighting such a fire...
declares an array of immutable pointers, hence repeating the constness for each member is redundant (not useful, not hurting).
|
Luca Ceresoli <lucaceresoli> |
Fri 26 Mar 2010 02:14:57 PM UTC, comment #16:
|
Simon Goldschmidt <goldsimon> |
Fri 26 Mar 2010 02:01:06 PM UTC, comment #15: It's not a syntax error - it's a semantic error that some compilers have decided to warn about an unnecessary pointer qualifier. Just like some compilers say the & on a function is not needed and others don't.
|
Bill Auerbach <billauerbach> |
Fri 26 Mar 2010 01:54:32 PM UTC, comment #14: BTW: I don't insist on changing this, but there seems to be something wrong with it or Luca's compiler wouldn't warn and "cdecl" wouldn't say it's a syntax error. |
Simon Goldschmidt <goldsimon> |
Fri 26 Mar 2010 01:53:05 PM UTC, comment #13: The problem with no casts in the array initializer is that the array elements have a different type than the array itself. |
Simon Goldschmidt <goldsimon> |
Fri 26 Mar 2010 01:47:44 PM UTC, comment #12: Here's what I agree to: :-)
|
Bill Auerbach <billauerbach> |
Fri 26 Mar 2010 01:43:10 PM UTC, comment #11: Except that the thing it points to IS const... |
Bill Auerbach <billauerbach> |
Fri 26 Mar 2010 01:42:27 PM UTC, comment #10: grr, asterisks in previous comment seem to have been interpreted as making things bold. Sounds like we're all in agreement though about the meaning of current code, but we're not sure why it was written that way. |
Kieran Mansley <kieranm> |
Fri 26 Mar 2010 01:40:21 PM UTC, comment #9: Posted too fast: maybe it's not so weird. I think it's trying to say that the pointer is a const, rather than the thing it points to being a const. i.e. if you have
|
Kieran Mansley <kieranm> |
Fri 26 Mar 2010 01:39:28 PM UTC, comment #8: This is what cdecl has to say about the two versions:
|
Simon Goldschmidt <goldsimon> |
Fri 26 Mar 2010 01:38:56 PM UTC, comment #7: Ok, I see. I was showing (initially) why the original const had a warning and thought the intent was the pointer was to const, and it should be.
|
Bill Auerbach <billauerbach> |
Fri 26 Mar 2010 01:30:18 PM UTC, comment #6: The current code is weird then. I'm not sure what struct mib_node* const snmp_nodes[28] is supposed to mean either. |
Kieran Mansley <kieranm> |
Fri 26 Mar 2010 01:20:37 PM UTC, comment #5:
|
Simon Goldschmidt <goldsimon> |
Fri 26 Mar 2010 12:55:39 PM UTC, comment #4:
|
Bill Auerbach <billauerbach> |
Fri 26 Mar 2010 12:48:20 PM UTC, comment #3: But that means something different than:
|
Simon Goldschmidt <goldsimon> |
Fri 26 Mar 2010 12:31:10 PM UTC, comment #2: const is allowed in a cast, but it matters where:
|
Bill Auerbach <billauerbach> |
Fri 26 Mar 2010 10:34:25 AM UTC, comment #1: Hmm, I don't get any warning with or without the "const"s removed by the patch. Also, I didn't find any documentation on whether that "const" is allowed in casts (it is allowed in declarations, so why not in casts?), and the "cdecl" tool tells me this is a "syntax error"...
|
Simon Goldschmidt <goldsimon> |
Tue 23 Mar 2010 04:19:46 PM UTC, original submission:
While compiling mib3.c, my compiler issues a lot of
|
Luca Ceresoli <lucaceresoli> |
Depends on the following items: None found
Items that depend on this one: None found
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 |
---|---|---|---|---|---|
2010-03-27 | goldsimon | Status | Need Info | Done | |
Assigned to | None | goldsimon | |||
Open/Closed | Open | Closed | |||
2010-03-26 | goldsimon | Status | None | Need Info | |
2010-03-23 | lucaceresoli | Attached File | - | Added mib2-const.patch, #20007 |
Powered by Savane 3.13-02a9.
Corresponding source code
Checked in.