On Wed, 23 Dec 2009 18:14:57 -0500
Christopher Michael <cpmicha...@comcast.net> wrote:

> On 12/23/2009 06:01 PM, Vincent Torri wrote:
> >
> >
> > On Wed, 23 Dec 2009, Enlightenment SVN wrote:
> >
> >> Log:
> >>   When using snprintf or fgets, etc, do not use PATH_MAX directly
> >> as the size of the variable...use sizeof() compiler directive
> >> (lots of these).
> >
> > that's something i don't understand.
> >
> > char buf[PATH_MAX] is an array of size PATH_MAX in bytes
> > and sizeof(buf) returns the size of buf in bytes, which is also
> > PATH_MAX
> >
> > so what is the interest of using sizeof() instead of PATH_MAX ?
> >
> > Vincent
> 
> A little while ago I had changed snprintf's in several spots todo
> just that...PATH_MAX rather than sizeof()...raster suggested against
> it and had a valid reason (can't remember it now, but if you grep the
> mailing list archives I am sure you will find the discussion)

If someone changes 
        char buf[PATH_MAX] to 
        char buf[BUFSIZ] 
there is no chance of forgetting to change the snprintf.

Essentially the eternal principle of only saying something once in code.

        Regards,
        nash

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to