Re: [PATCH_v2 1/4] android/pan: Register Network Access Point

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

 



Hi Ravi,

On Tue, Jan 07, 2014, Ravi kumar Veeramally wrote:
> +static int set_forward_delay(void)
> +{
> +	FILE *f;
> +	char *path;
> +
> +	path = g_strdup_printf("/sys/class/net/%s/bridge/forward_delay",
> +								BNEP_BRIDGE);
> +	if (!path)
> +		return -ENOMEM;
> +
> +	f = fopen(path, "r+");
> +	g_free(path);
> +	if (!f)
> +		return -errno;

The above is not safe since g_free() might modify the value of errno.

In general, we're not really in the habit of using the f* variants of
file access functions. Could you convert the above to use a stack
variable for path (there's a PATH_MAX variable you can use for its
size) together with sprintf and use open + write instead of fopen +
fprintf?

> +static int nap_create_bridge(void)
> +{
> +	int sk, err;
> +
> +	DBG(" %s", BNEP_BRIDGE);

Why the extra space before %s?


> +	if (ioctl(sk, SIOCBRADDBR, BNEP_BRIDGE) == -1) {

We usually check for this kind of errors with < 0 instead of == -1.

> +	DBG(" %s", BNEP_BRIDGE);

Same thing here with the seemingly unnecessary space.

Johan
--
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