Re: non-linux support

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

 



On Sun, Nov 04, 2007 at 04:34:54PM +0000, Samuel Thibault wrote:
> Samuel Thibault, le Sun 12 Aug 2007 16:12:56 +0200, a écrit :
> > Mike Frysinger, le Sun 12 Aug 2007 10:07:01 -0400, a écrit :
> > > > The above patch is just to avoid the risky exercice which is rewriting
> > > > of code into length-unlimited loop. But MAXPATHLEN & such should really
> > > > used as "oops, the system is limited to this", not as "how much memory
> > > > should I allocate for my path?". Some system may very well define
> > > > MAXPATHLEN to MAXINT...
> > > 
> > > ah, i missed the statement in POSIX where these defines may be omitted ... may 
> > > be worthwhile i think to go through the code and just get rid of usage of all 
> > > of these _MAX defines by querying the actual limits at runtime ...
> > 
> > There may be no runtime limit either actually.
> 
> Here is an updated patch. fdiskbsdlabel.c actually exactly knows how big
> its buffer should be. agetty.c already had a generic macro, but just

 I prefer patch per tool and patch per problem. Please, don't mix
 multiple things in one patch.

>    char *bootdir = BSD_LINUX_BOOTDIR;
> -  char path[MAXPATHLEN];
> +  char path[strlen(BSD_LINUX_BOOTDIR) + 1 + 2 + 4 + 1];

 s/strlen/sizeof/

 magic constants "1 + 2 + 4 + 1" doesn't look nice. What about to use
 malloc(), particularly when the final path depends on users input.


> -		     char domainname[HOST_NAME_MAX+1];
> +		     char domainname[HOSTNAME_LENGTH+1];
 ...

> +#ifndef MAXHOSTNAMELEN
> +#define MAXHOSTNAMELEN 64
> +#endif

 We perfectionists love only one definition on only one place. I
 suggest something like include/constants.h.


> +#ifdef HAVE_GET_CURRENT_DIR_NAME
> +    char *curdir;
> +#else
>      char curdir[MAXPATHLEN];
> +#endif

 ...

> +#ifndef PATH_MAX
> +#define PATH_MAX 4096
> +#endif

 Ah, MAXPATHLEN, PATH_MAX, but we perfectionists love...

    Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux