Hi Jan,

Thank you for the review.

Jan Safranek wrote:
> Ken'ichi Ohmichi wrote:
>> Hi,
>>
>> By using sizeof() in memset(), we will not need to care of the buffer
>> size.
>>
>>
>> Thanks
>> Ken'ichi Ohmichi
>>
>> Signed-off-by: Ken'ichi Ohmichi <[email protected]>
>> ---
>>  src/api.c |   37 +++++++++++++------------------------
>>  1 files changed, 13 insertions(+), 24 deletions(-)
>>
>> diff --git a/src/api.c b/src/api.c
>> index 4f88d20..75dc92a 100644
>> --- a/src/api.c
>> +++ b/src/api.c
>> @@ -268,7 +268,7 @@ static int cgroup_parse_rules(bool cache, uid_t
>> muid, gid_t mgid)
>>      FILE *fp = NULL;
>>  
>>      /* Buffer to store the line we're working on */
>> -    char *buff = NULL;
>> +    char buff[CGROUP_RULE_MAXLINE] = { '\0' };
>>  
>>      /* Iterator for the line we're working on */
>>      char *itr = NULL;
>> @@ -322,14 +322,6 @@ static int cgroup_parse_rules(bool cache, uid_t
>> muid, gid_t mgid)
>>          goto unlock;
>>      }
>>  
>> -    buff = calloc(CGROUP_RULE_MAXLINE, sizeof(char));
>> -    if (!buff) {
>> -        cgroup_dbg("Out of memory?  Error: %s\n", strerror(errno));
>> -        last_errno = errno;
>> -        ret = ECGOTHER;
>> -        goto close;
>> -    }
>> -
>>      /* Determine which list we're using. */
>>      if (cache)
>>          lst = &rl;
>> @@ -342,7 +334,7 @@ static int cgroup_parse_rules(bool cache, uid_t
>> muid, gid_t mgid)
>>  
>>      /* Now, parse the configuration file one line at a time. */
>>      cgroup_dbg("Parsing configuration file.\n");
>> -    while ((itr = fgets(buff, CGROUP_RULE_MAXLINE, fp)) != NULL) {
>> +    while ((itr = fgets(buff, sizeof(buff), fp)) != NULL) {
>>          linenum++;
>>  
>>          /* We ignore anything after a # sign as comments. */
>> @@ -354,7 +346,7 @@ static int cgroup_parse_rules(bool cache, uid_t
>> muid, gid_t mgid)
>>              *itr = '\0';
>>  
>>          /* Now, skip any leading tabs and spaces. */
>> -        itr = buff;
>> +        itr = &buff;
> 
> Ths leads to warning: assignment from incompatible pointer type. Better
> keep it as it was: itr = buff;.

You are right, I'll send a new version by fixing it.


Thanks
Ken'ichi Ohmichi

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to