lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [task #7142] Sanity check user-configurable values


From: Frédéric Bernon
Subject: [lwip-devel] [task #7142] Sanity check user-configurable values
Date: Wed, 29 Aug 2007 09:22:50 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6

Follow-up Comment #6, task #7142 (project lwip):

No, lwip_init is checked in, but not include - yet - this feature, but it
can/should be the right place to add these sanity checkings, since some of
them can only be done at runtime (the "warnings"). To give background, I
copy/paste here the part of IRC chat where we talk about that with Jonathan:


[17:26] <fbernon> I would like to add at the end of opt.h some of the checks
about "task #7142 : Sanity check user-configurable values"
[17:26] <fbernon> Since they can avoid some questions
[17:27] <fbernon> is it ok for you ?
[17:36] <jifl> Sure, fire away
[17:37] <jifl> I'd probably put some demarcation and say "no user edittable
stuff below this line"
[17:37] <jifl> So users don't think it's stuff they need to change
[17:39] <fbernon> if they copy/paste opt.h to create their lwipopts.h ?
[17:44] <fbernon> or we could include a "optcheck.h" at the end of opt.h ?
[17:47] <jifl> if i were a user, i would copy/paste opt.h to make
lwipopts.h.
[17:47] <jifl> (personally)
[17:47] <jifl> optcheck.h might be an idea. I'm fine with that.
[17:48] <fbernon> ok
[17:48] <fbernon> is there any standard preprocessor instruction, like
#error, but to only display a message ?
[17:49] <fbernon> which is C ANSI, of course...
[17:49] <jifl> no
[17:50] <jifl> I think #warning might be in C99
[17:50] <jifl> but not C90
[17:50] <jifl> so that would not be portable
[17:50] <jifl> for any warnings, I was going to check those at runtime
[17:50] <jifl> Put them in a #if LWIP_DEBUG block in sys_init() or something
like that
[17:51] <fbernon> If we had a lwip_init, it would be the good place
...
[17:54] <fbernon> is there any standard define like "__cplusplus" to know if
the compiler is C99 compliant ?
[17:56] <jifl> Yes
[17:56] <jifl> I'll dig it up
[17:57] <jifl> _STDC_VERSION_
[17:58] <jifl> This will be 199901L for C99
[17:59] <fbernon> So, we can do "warning" check in a "#if _STDC_VERSION_ /
#endif" block ?
[17:59] <jifl> C90 doesn't define it
[18:00] <fbernon> ok, old compiler won't do these checks, but it's just a
"helper" after all...
[18:01] <jifl> I'm not sure that would work. I think the preprocessor still
expects to be able to parse lines beginning with '#'
[18:01] <jifl> Or at least, not work portably
[18:01] <jifl> I still think it's better to check for things to warn about at
runtime in one of the init functions
[18:03] <fbernon> problem: if you don't activate LWIP_DEBUG, you don't have
these check
[18:03] <jifl> That's true.
[18:05] <jifl> I was going to suggest that LWIP_DEBUG be on by default. But I
see something more odd - LWIP_DEBUG isn't in opt.h at all.
[18:05] <fbernon> yes
[18:06] <fbernon> most of time, it is checked by #ifdef and not #if
[18:06] <fbernon> same for LWIP_NOASSERT
[18:06] <jifl> It should probably be in opt.h, so people know it exists to
change in lwipopt.h
[18:06] <jifl> lwipopts.h
[18:06] <fbernon> I don't find that very nice
[18:07] <jifl> Even if commented out
[18:07] <fbernon> replace in debug.h the #ifdef LWIP_DEBUG... by a #if
LWIP_DEBUG will be better
[18:08] <fbernon> but it's another port-breakage
[18:08] <jifl> I agree. Although 1.3.0 is about port breakage :-)
[18:09] <fbernon> yes
[18:09] <fbernon> before change that, I will post the change on task #7142

[18:21] <fbernon> we are talking about put LWIp_DEBUG and LWIP_NOASSERT in
opt.h, with a change in debug.h
[18:21] <fbernon> but it cause another port-breakage
[18:22] <fbernon> this idea is to get LWIP_DEBUG per default, and to do all
sanity check at runtime in sys_init (or any other)
[18:23] <jaredgrubb> ok
[18:23] <fbernon> I talk about task #7142
[18:23] <jaredgrubb> i havent used the debug in lwip at all... so i may not
be much help there
[18:23] <jifl> it doesn't make much difference if everything works :-)
[18:24] <fbernon> and of course, all works fine at the first try with lwIP
;)
[18:24] <jifl> All the individual modules to be debugged have their debug
output set at LWIP_DBG_OFF
[18:24] <jifl> (by default)
[18:25] <fbernon> yes, but even like this, you add the code of the LWIP_DEBUG
macro
[18:25] <jifl> Sort of - for a disabled module, the macro would become
something like:
[18:26] <jifl> do { if ((((0) & 0x80U) && ......
[18:26] <fbernon> the code won't do anything, since you got a if (0), but,
except some good compiler/linker, the code is here
[18:26] <jifl> any optimising compiler will get rid of that
[18:27] <fbernon> I'm agree 


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/task/?7142>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]