-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
This review of the C code was offered by Christos:
- you should either check
strdupor use stack storage (I would use stack storage, since you can only bePATH_MAX). - you made it unnecessarily linux-specific by including linux only headers. There is
limits.hfor example. sysexits.his unused and obsolete (usestdlib.hEXIT_SUCCESS/EXIT_FAILURE)- use
err/warn{,x}from<err.h>instead offprintfto report errors (that way you don't need to hard-code the program name. - don't use
memmoveunless the memory can be overlapping; here it never is (memcpyis good enough) - argument order should be
(char *dst, size_t dstsize, const char *src); this is the convention (seesnprintfetc). _var names are reserved by the implementationfollow_linkcould be made static.ARG_MAXis not the length of an individual argument; it is the combined size of theargv + envpspace that can be passed to exec. It is usually pretty big and for you it is a lot bigger since it is* sizeof (char *). But you really never have to worry about that because the shebang length is 128 on linux and typically less than that (the kernel will never pass you more), so don't useARG_MAX(now you don't needlimits.h) just use something like 128 for the number of arguments and it will be good enough.- you should make
joinpathalways seterrnoso you can useerr()and print a sensible error like you do infollow_link.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels