[PATCH 2.5/5] matchDriverFromFiles: use one snprintf instead of strncpy/cat series
Jeremy Huddleston
jeremyhu at apple.com
Sat Oct 29 15:06:03 PDT 2011
Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
On Oct 29, 2011, at 10:39, Alan Coopersmith wrote:
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
>
> Split out of the prior patch "Convert strncpy/strncat to strlcpy/strlcat"
>
> hw/xfree86/common/xf86pciBus.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
> index b4d59e1..c8823e7 100644
> --- a/hw/xfree86/common/xf86pciBus.c
> +++ b/hw/xfree86/common/xf86pciBus.c
> @@ -1210,9 +1210,8 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
> /* A tiny bit of sanity checking. We should probably do better */
> if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
> /* We need the full path name to open the file */
> - strncpy(path_name, PCI_TXT_IDS_PATH, 256);
> - strncat(path_name, "/", 1);
> - strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
> + snprintf(path_name, sizeof(path_name), "%s/%s",
> + PCI_TXT_IDS_PATH, direntry->d_name);
> fp = fopen(path_name, "r");
> if (fp == NULL) {
> xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
> --
> 1.7.3.2
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list