On Mon, Apr 26, 2010 at 6:04 AM, Cyril Hrubis <[email protected]> wrote:
> Hi!
> Fixed version attached.
>
> Signed-off-by: Cyril Hrubis [email protected]
Some concerns I have about tst_get_path are as follows:
1. A good portion of the logic in the function could be replaced with
strchr(3) calls.
2. Why do you feel this is required?
3. This should really be a single snprintf call:
+ /* copy path */
+ for (i = 0; i < buf_len && path[i] != '\0' && path[i] != ':';
i++)
+ buf[i] = path[i];
+
+ /* add slash at the end if needed */
+ if (buf[i - 1] != '/')
+ buf[i++] = '/';
+ /* copy the program name */
+ strncpy(buf + i, prog_name, buf_len - i);
similar to the following:
if (snprintf(buf, buf_len, "%s/%s", path_element, prog_name) > buf_len)
/* error out */
else if (file_exist(buf))
return 0; /* etc... */
/* ... */
The loop conditional will need to be adjusted so that it ensures
that there are more path delimiters via ':' of course though.
Thanks,
-Garrett
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list