All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/hci2hid: properly format device path
@ 2013-11-04  1:46 Matthew Monaco
  2013-11-04 16:18 ` Vinicius Costa Gomes
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Monaco @ 2013-11-04  1:46 UTC (permalink / raw)
  To: linux-bluetooth

From: Matthew Monaco <matthew.monaco@0x01b.net>

---
Hello! I hope this is the correct place to send a bugfix for bluez.
 tools/hid2hci.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/hid2hci.c b/tools/hid2hci.c
index bb8a521..8f22047 100644
--- a/tools/hid2hci.c
+++ b/tools/hid2hci.c
@@ -221,18 +221,21 @@ static int usb_switch_dell(int fd, enum mode mode)
 static int find_device(struct udev_device *udev_dev)
 {
 	char path[PATH_MAX];
-	const char *busnum, *devnum;
+	const char *str;
+	long int busnum, devnum;
 	int fd;
 
-	busnum = udev_device_get_sysattr_value(udev_dev, "busnum");
-	if (!busnum)
+	str = udev_device_get_sysattr_value(udev_dev, "busnum");
+	if (!str)
 		return -1;
+	busnum = strtol(str, NULL, 0);
 
-	devnum = udev_device_get_sysattr_value(udev_dev, "devnum");
-	if (!devnum)
+	str = udev_device_get_sysattr_value(udev_dev, "devnum");
+	if (!str)
 		return -1;
+	devnum = strtol(str, NULL, 0);
 
-	snprintf(path, sizeof(path), "/dev/bus/usb/%s/%s", busnum, devnum);
+	snprintf(path, sizeof(path), "/dev/bus/usb/%03d/%03d", busnum, devnum);
 
 	fd = open(path, O_RDWR, O_CLOEXEC);
 	if (fd < 0) {
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] tools/hci2hid: properly format device path
  2013-11-04  1:46 [PATCH] tools/hci2hid: properly format device path Matthew Monaco
@ 2013-11-04 16:18 ` Vinicius Costa Gomes
  2013-11-04 16:23   ` Bastien Nocera
  0 siblings, 1 reply; 5+ messages in thread
From: Vinicius Costa Gomes @ 2013-11-04 16:18 UTC (permalink / raw)
  To: Matthew Monaco; +Cc: linux-bluetooth

Hi Matthew,

On 18:46 Sun 03 Nov, Matthew Monaco wrote:
> From: Matthew Monaco <matthew.monaco@0x01b.net>
> 
> ---
> Hello! I hope this is the correct place to send a bugfix for bluez.
>  tools/hid2hci.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)

The patch itself looks good.

What I think is missing is a better description of the problem it solves, I
would suggest including in the commit message the values of 'path' for before
and after the patch, for a situation that the current implementation doesn't
work.

Changing the subject line to something like: "tools: Fix wrong paths for
adapters" would make it easier to tell that this patch is indeed a bug fix.

> 
> diff --git a/tools/hid2hci.c b/tools/hid2hci.c
> index bb8a521..8f22047 100644
> --- a/tools/hid2hci.c
> +++ b/tools/hid2hci.c
> @@ -221,18 +221,21 @@ static int usb_switch_dell(int fd, enum mode mode)
>  static int find_device(struct udev_device *udev_dev)
>  {
>  	char path[PATH_MAX];
> -	const char *busnum, *devnum;
> +	const char *str;
> +	long int busnum, devnum;
>  	int fd;
>  
> -	busnum = udev_device_get_sysattr_value(udev_dev, "busnum");
> -	if (!busnum)
> +	str = udev_device_get_sysattr_value(udev_dev, "busnum");
> +	if (!str)
>  		return -1;
> +	busnum = strtol(str, NULL, 0);
>  
> -	devnum = udev_device_get_sysattr_value(udev_dev, "devnum");
> -	if (!devnum)
> +	str = udev_device_get_sysattr_value(udev_dev, "devnum");
> +	if (!str)
>  		return -1;
> +	devnum = strtol(str, NULL, 0);
>  
> -	snprintf(path, sizeof(path), "/dev/bus/usb/%s/%s", busnum, devnum);
> +	snprintf(path, sizeof(path), "/dev/bus/usb/%03d/%03d", busnum, devnum);
>  
>  	fd = open(path, O_RDWR, O_CLOEXEC);
>  	if (fd < 0) {
> -- 
> 1.8.4.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers,
-- 
Vinicius

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tools/hci2hid: properly format device path
  2013-11-04 16:18 ` Vinicius Costa Gomes
@ 2013-11-04 16:23   ` Bastien Nocera
  2013-11-04 16:42     ` Vinicius Costa Gomes
  0 siblings, 1 reply; 5+ messages in thread
From: Bastien Nocera @ 2013-11-04 16:23 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: Matthew Monaco, linux-bluetooth

On Mon, 2013-11-04 at 14:18 -0200, Vinicius Costa Gomes wrote:
> Hi Matthew,
> 
> On 18:46 Sun 03 Nov, Matthew Monaco wrote:
> > From: Matthew Monaco <matthew.monaco@0x01b.net>
> > 
> > ---
> > Hello! I hope this is the correct place to send a bugfix for bluez.
> >  tools/hid2hci.c | 15 +++++++++------
> >  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> The patch itself looks good.
> 
> What I think is missing is a better description of the problem it solves, I
> would suggest including in the commit message the values of 'path' for before
> and after the patch, for a situation that the current implementation doesn't
> work.
> 
> Changing the subject line to something like: "tools: Fix wrong paths for
> adapters" would make it easier to tell that this patch is indeed a bug fix.

Isn't this the same patch Giovanni sent a couple of weeks ago?

http://thread.gmane.org/gmane.linux.bluez.kernel/38329

Cheers


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tools/hci2hid: properly format device path
  2013-11-04 16:23   ` Bastien Nocera
@ 2013-11-04 16:42     ` Vinicius Costa Gomes
  2013-11-04 16:52       ` Matthew Monaco
  0 siblings, 1 reply; 5+ messages in thread
From: Vinicius Costa Gomes @ 2013-11-04 16:42 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: Matthew Monaco, linux-bluetooth

Hi Bastien,

On 17:23 Mon 04 Nov, Bastien Nocera wrote:
> On Mon, 2013-11-04 at 14:18 -0200, Vinicius Costa Gomes wrote:
> > Hi Matthew,
> > 
> > On 18:46 Sun 03 Nov, Matthew Monaco wrote:
> > > From: Matthew Monaco <matthew.monaco@0x01b.net>
> > > 
> > > ---
> > > Hello! I hope this is the correct place to send a bugfix for bluez.
> > >  tools/hid2hci.c | 15 +++++++++------
> > >  1 file changed, 9 insertions(+), 6 deletions(-)
> > 
> > The patch itself looks good.
> > 
> > What I think is missing is a better description of the problem it solves, I
> > would suggest including in the commit message the values of 'path' for before
> > and after the patch, for a situation that the current implementation doesn't
> > work.
> > 
> > Changing the subject line to something like: "tools: Fix wrong paths for
> > adapters" would make it easier to tell that this patch is indeed a bug fix.
> 
> Isn't this the same patch Giovanni sent a couple of weeks ago?
> 
> http://thread.gmane.org/gmane.linux.bluez.kernel/38329

Yeah, same fix. Thanks for noticing.

> 
> Cheers
> 


Cheers,
-- 
Vinicius

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tools/hci2hid: properly format device path
  2013-11-04 16:42     ` Vinicius Costa Gomes
@ 2013-11-04 16:52       ` Matthew Monaco
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Monaco @ 2013-11-04 16:52 UTC (permalink / raw)
  To: Vinicius Costa Gomes, Bastien Nocera; +Cc: linux-bluetooth

Ah, didn't see it in git. Sorry about the noise.

On 11/04/2013 09:42 AM, Vinicius Costa Gomes wrote:
> Hi Bastien,
> 
> On 17:23 Mon 04 Nov, Bastien Nocera wrote:
>> On Mon, 2013-11-04 at 14:18 -0200, Vinicius Costa Gomes wrote:
>>> Hi Matthew,
>>>
>>> On 18:46 Sun 03 Nov, Matthew Monaco wrote:
>>>> From: Matthew Monaco <matthew.monaco@0x01b.net>
>>>>
>>>> ---
>>>> Hello! I hope this is the correct place to send a bugfix for bluez.
>>>>  tools/hid2hci.c | 15 +++++++++------
>>>>  1 file changed, 9 insertions(+), 6 deletions(-)
>>>
>>> The patch itself looks good.
>>>
>>> What I think is missing is a better description of the problem it solves, I
>>> would suggest including in the commit message the values of 'path' for before
>>> and after the patch, for a situation that the current implementation doesn't
>>> work.
>>>
>>> Changing the subject line to something like: "tools: Fix wrong paths for
>>> adapters" would make it easier to tell that this patch is indeed a bug fix.
>>
>> Isn't this the same patch Giovanni sent a couple of weeks ago?
>>
>> http://thread.gmane.org/gmane.linux.bluez.kernel/38329
> 
> Yeah, same fix. Thanks for noticing.
> 
>>
>> Cheers
>>
> 
> 
> Cheers,
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-04 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-04  1:46 [PATCH] tools/hci2hid: properly format device path Matthew Monaco
2013-11-04 16:18 ` Vinicius Costa Gomes
2013-11-04 16:23   ` Bastien Nocera
2013-11-04 16:42     ` Vinicius Costa Gomes
2013-11-04 16:52       ` Matthew Monaco

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.