[MPlayer-dev-eng] [patch 2/5] Dont hardcode filename length

Diego Biurrun diego at biurrun.de
Wed Jan 5 13:06:59 CET 2011


On Wed, Jan 05, 2011 at 11:43:51AM +0100, Erik Auerswald wrote:
> 
> On Tue, Jan 04, 2011 at 09:35:03PM +0100, Tobias Diedrich wrote:
> > Use limits.h to get the maximum length instead of hardcoding it.
> > 
> > -     fname=malloc( 255 );
> > -     while ( fgets( fname,255,lst_f ) )
> > +     fname=malloc(PATH_MAX);
> > +     while ( fgets( fname,PATH_MAX,lst_f ) )
> 
> FWIW there is no guarantee that PATH_MAX even exists. See e.g.
> http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html or
> http://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html or
> http://bytes.com/topic/c/answers/215365-path_max

False, POSIX requires it:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html#tag_13_23_03_02

So relying on the existence of PATH_MAX is not a problem.
Also, it is being used in other places already.

Diego


More information about the MPlayer-dev-eng mailing list