Hi Johan,
On 11/23/2010 2:53 PM, Johan Hedberg wrote:
In general the patch looks ok'ish, but:
> + if (set_speed(fd, ti, speed)< 0) {
> + perror("Can't set required baud rate");
> + return -1;
> + }
To be consistent with the other return values, instead of -1 you should
be returning a proper errno here. I.e. probably something like:
if (set_speed(fd, ti, speed)< 0) {
err = -errno;
perror("Can't set required baud rate");
return err;
The set_speed function is defined in hciattach.c as
int set_speed(...)
{
cfsetospeed(...);
cfsetispeed(...);
return tcsetattr(...);
}
I think this function could end up returning Success even if the first
two function calls failed?
Does it makes sense to rewrite it to
int set_speed(...)
{
if(cfsetospeed(...) < 0)
return -errno;
if(cfsetispeed(...) < 0)
return -errno;
return tcsetattr(...);
}
Then, I can return the error code directly in my function call.
Regards
Suraj
--
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