patchlwIP - A Lightweight TCP/IP stack - Patches: patch #5811, Fix negative statistical counter...

 
 

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

patch #5811: Fix negative statistical counter display

Submitter:  Tai-hwa Liang <atliang>
Submitted:  Thu 22 Mar 2007 01:46:29 AM UTC
   
 
Category:  None Priority:  3 - Low
Status:  Done Privacy:  Public
Assigned to:  fbernon Open/Closed:  Closed
Planned Release:  None

Jump to the original submission

Thu 22 Mar 2007 04:38:58 PM UTC, comment #7: 

Good for me, and commit in CVS.

See CHANGELOG if you need u32_t counters.

Frédéric Bernon <fbernon>
Group Member
Thu 22 Mar 2007 10:24:36 AM UTC, comment #6: 

OK

Kieran Mansley <kieranm>
Group Member
Thu 22 Mar 2007 10:06:00 AM UTC, comment #5: 

I already got the problem, even if I don't use every day LWIP_STATS - and never in production - with some counters (xmit & recv if I remember), which can overflow very fast.

I suppose the remark if about adding LWIP_STATS_LARGE in opt.h (which is "visible" tunning part)? If this is the case, perhaps we can put it in stats.h, just after "#if LWIP_STATS" ?

About names, perhaps these are better :

#if LWIP_LARGE_STATS
#define STAT_COUNTER   u32_t
#define STAT_COUNTER_F U32_F
#else
#define STAT_COUNTER   u16_t
#define STAT_COUNTER_F U16_F
#endif

Good for you?


Frédéric Bernon <fbernon>
Group Member
Thu 22 Mar 2007 09:56:28 AM UTC, comment #4: 

Is it something that you (or others?) would find useful?  If so, I can't see any reason to object, but I wouldn't worry about it if no one has asked for it.

Kieran Mansley <kieranm>
Group Member
Thu 22 Mar 2007 09:54:19 AM UTC, comment #3: 

Ok, but a simple idea :

In opt.h:

#ifndef LWIP_STATS_LARGE
#define LWIP_STATS_LARGE 0
#endif

In stats.h

#if LWIP_STATS_LARGE
#define STATCOUNTER  u32_t
#define STATFORMATER U32_F
#else
#define STATCOUNTER  u16_t
#define STATFORMATER U16_F
#endif

struct stats_proto {
  STATCOUNTER xmit;    /* Transmitted packets. */
  STATCOUNTER rexmit;  /* Retransmitted packets. */
  ...
};
...

And in stats.c:

void
stats_display_proto(struct stats_proto *proto, char *name)
{
  LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
  LWIP_PLATFORM_DIAG(("xmit: %"STATFORMATER"\n\t", proto->xmit));
  LWIP_PLATFORM_DIAG(("rexmit: %"STATFORMATER"\n\t", proto->rexmit));
   ...
}
...

Ok for that ?

Frédéric Bernon <fbernon>
Group Member
Thu 22 Mar 2007 09:04:12 AM UTC, comment #2: 

I think go ahead with this patch as it stands if you're happy with it Frederic.  The issue you followed up with is essentially another problem, which we can do something about later if required.

Kieran Mansley <kieranm>
Group Member
Thu 22 Mar 2007 08:26:36 AM UTC, comment #1: 

Seems good for me for most (and because all stats fields are actually in u16_t). But sometimes, a negative value can indicate a problem in the stack ("two dec for 1 inc" by example). Perhaps it will be usefull to use s32_t or u32_t if you reach limits?

I will commit (with U16_F) this morning if no objection...


Frédéric Bernon <fbernon>
Group Member
Thu 22 Mar 2007 01:46:29 AM UTC, original submission:  

The attached patch changed the format string in various stats_display_XXX() from signed to unsigned.

This does not fix the 16 bit overflow problem; however, the overflowed number would no longer be a negative integer, which is less scary. ;)

Tai-hwa Liang <atliang>

 

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

Attached Files
file #12230:  stats.c.patch added by atliang (3KiB - application/octet-stream - Patch to fix negative statistical counter display)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kieranm (Posted a comment)
  • -email is unavailable- added by fbernon (Posted a comment)
  • -email is unavailable- added by atliang (Submitted the item)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-03-22 fbernon StatusNone Done
        Open/ClosedOpen Closed
    2007-03-22 fbernon Assigned toNone fbernon
    2007-03-22 atliang Attached File- Added stats.c.patch, #12230

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code