On 03/10/2014 11:28 AM, Krzysztof Opasiak wrote:
> Hi,
> 
>> -----Original Message-----
>> From: Robert Baldyga [mailto:r.bald...@samsung.com]
>> Sent: Monday, March 10, 2014 10:43 AM
>> To: Krzysztof Opasiak; mpor...@linaro.org; linux-
>> u...@vger.kernel.org
>> Cc: Andrzej Pietrasiewicz; Karol Lewandowski; Stanislaw Wadas;
>> ty317....@samsung.org; Marek Szyprowski
>> Subject: Re: [PATCH 1/6] libusbg: Add remove binding functionality.
>>
>> Hi,
>>
>>> diff --git a/src/usbg.c b/src/usbg.c
>>> index f655675..e82658c 100644
>>> --- a/src/usbg.c
>>> +++ b/src/usbg.c
>>> @@ -142,6 +142,7 @@ static int usbg_translate_error(int error)
>>>             break;
>>>     case EACCES:
>>>     case EROFS:
>>> +   case EPERM:
>>>             ret = USBG_ERROR_NO_ACCESS;
>>>             break;
>>>     case ENOENT:
>>> @@ -450,6 +451,22 @@ static void usbg_free_state(usbg_state *s)
>>>     free(s);
>>>  }
>>>
>>> +static int usbg_remove_file(char *path, char *name)
>>> +{
>>> +   int ret;
>>> +   char buf[USBG_MAX_PATH_LENGTH];
>>> +
>>> +   sprintf(buf, "%s/%s", path, name);
>>
>> Maybe snprintf would be better?
> 
> There is much more sprintf in library. All those functions will be
> replaced with snprintf when removing satic buffers and handling
> overflows. So it is future work in whole library
> 

Function snprintf should be used particularly with static buffers. When
you use dynamically allocated buffer you can adjust its size, and then
snprintf is not needed.

>>
>>> +   ret = unlink(buf);
>>> +   if (ret != 0)
>>> +           ret = usbg_translate_error(errno);
>>> +   else
>>> +           ret = USBG_SUCCESS;
>>> +
>>> +   return ret;
>>> +}
>>> +
>>>  static int usbg_parse_function_net_attrs(usbg_function *f,
>>>             usbg_function_attrs *f_attrs)
>>>  {
>>

Robert.

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

Reply via email to