Re: [PATCH BlueZ v2 1/2] plugins: Use open()/read() instead of fopen()/fread() on autopair

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

 



Hi Johan,

On Mon, May 20, 2013 at 7:51 PM, Johan Hedberg <johan.hedberg@xxxxxxxxx> wrote:
> Hi Lizardo,
>
> On Fri, May 17, 2013, Anderson Lizardo wrote:
>> +     fd = open("/dev/urandom", O_RDONLY);
>> +     if (fd < 0) {
>> +             ssize_t n;
>> +
>> +             n = read(fd, &seed, sizeof(seed));
>> +             if (n < (ssize_t) sizeof(seed))
>> +                     seed = time(NULL);
>> +
>> +             close(fd);
>> +     } else
>> +             seed = time(NULL);
>
> So, it's not always wise to go blindly copying code examples/suggestions
> from Marcel without thinking a bit. You're checking for invalid fd when
> you should be checking for a valid one (>= 0).

Sorry about letting this pass. I actually reviewed the snippet, but
was induced to some "braino" which now seems obvious.

I'll try to be more careful, specially given I could not test this
change (as I mentioned on the original patch, but not on this one).

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux