r205667 - [analyzer] Add an ErrnoChecker (PR18701) to the Potential Checkers list.

Jordan Rose jordan_rose at apple.com
Mon Apr 7 09:22:37 PDT 2014


On Apr 5, 2014, at 3:43 , Richard Osborne <richard at xmos.com> wrote:

> 
> On 5 Apr 2014, at 07:10, Jordan Rose <jordan_rose at apple.com> wrote:
>> 
>> +#include <stdlib.h>
>> +
>> +int readWrapper(int fd, int *count) {
>> +  int lcount = read(fd, globalBuf, sizeof(globalBuf));
>> +  if (lcount < 0)
>> +    return errno;
>> +  *count = lcount;
>> +  return 0;
>> +}
>> +
>> +void use(int fd) {
>> +  int count;
>> +  if (!readWrapper(fd))
> Should this be:
> 
> if (!readWrapper(fd, &count))
> 
>> +    print("%d", count); // should not warn
>> +}
> 

Ah, indeed it should be! Thanks, Richard. (Contrived examples are hard to get right.)



More information about the cfe-commits mailing list