RE: [PATCH 3/6] libusbg: Remove fixed-size buffers from usbg_config.

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

 



From: Krzysztof Opasiak
> Path and name length should not be placed in constant
> size buffer but in allocated memory.
> 
> Use also PATH_MAX macro from limits.h instead of internal
> library macro.

There might be some sense in keeping USBG_MAX_PATH_LENGTH
but defaulting to PATH_MAX.

...
> -	char cpath[USBG_MAX_PATH_LENGTH];
> +	char cpath[PATH_MAX];
> 
> -	sprintf(cpath, "%s/%s/%s", path, g->name, CONFIGS_DIR);
> +	n = snprintf(cpath, PATH_MAX, "%s/%s/%s", path, g->name, CONFIGS_DIR);

Use 'sizeof (path)' then it doesn't matter which literal is used
when the array is allocated.

	David


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux