Re: [avrdude-dev] linuxgpio: typo in snprintf() format string

2016-10-10 Thread 4ernov
Oh, thank you for pointing out, I've tried to search for some similar
bug in the bugzilla before writing, but missed this one for some
reason. Sorry for disturbing)

2016-10-10 9:39 GMT+03:00 Joerg Wunsch :
> Привет Алексей,
>
>> But it have turned
>> out, that the problem is with the typo in format string used in
>> "snprintf()" calls to create gpio pin filename: it specifies "%ud" for
>> unsigned integer value instead of just "%u"
>
> This has already been reported before:
>
> https://savannah.nongnu.org/bugs/index.php?47550
>
> It's fixed in the current source tree, awaiting a new release.
> --
> cheers, Joerg   .-.-.   --... ...--   -.. .  DL8DTL
>
> http://www.sax.de/~joerg/
> Never trust an operating system you don't have sources for. ;-)
>
> ___
> avrdude-dev mailing list
> avrdude-dev@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/avrdude-dev

___
avrdude-dev mailing list
avrdude-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avrdude-dev


[avrdude-dev] linuxgpio: typo in snprintf() format string

2016-10-09 Thread 4ernov
Hello,

I've tried to use recent 6.3 version with linuxgpio programmer enabled
and have failed with it with messages like "Can't export GPIO 31,
already exported/busy?: Device or resource busy". But it have turned
out, that the problem is with the typo in format string used in
"snprintf()" calls to create gpio pin filename: it specifies "%ud" for
unsigned integer value instead of just "%u", that's why we have likes
"31d" names, which "/sys/class/gpio/export" refuses to export.

The patch is applied. Hope it's helpful.

Best regards,
Alexey Chernov
diff -urB avrdude-6.3/linuxgpio.c avrdude-6.3-patched/linuxgpio.c
--- avrdude-6.3/linuxgpio.c	2016-02-15 23:16:32.0 +0300
+++ avrdude-6.3-patched/linuxgpio.c	2016-10-10 00:59:28.0 +0300
@@ -66,7 +66,7 @@
 return fd;
   }
 
-  len = snprintf(buf, sizeof(buf), "%ud", gpio);
+  len = snprintf(buf, sizeof(buf), "%u", gpio);
   r = write(fd, buf, len);
   close(fd);
 
@@ -84,7 +84,7 @@
 return fd;
   }
 
-  len = snprintf(buf, sizeof(buf), "%ud", gpio);
+  len = snprintf(buf, sizeof(buf), "%u", gpio);
   r = write(fd, buf, len);
   close(fd);
 
@@ -95,7 +95,7 @@
 {
   char filepath[60];
 
-  snprintf(filepath, sizeof(filepath), "/sys/class/gpio/gpio%ud/value", gpio);
+  snprintf(filepath, sizeof(filepath), "/sys/class/gpio/gpio%u/value", gpio);
   return (open(filepath, O_RDWR));
 }
 
@@ -104,7 +104,7 @@
   int fd, r;
   char buf[60];
 
-  snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%ud/direction", gpio);
+  snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%u/direction", gpio);
 
   fd = open(buf, O_WRONLY);
   if (fd < 0) {
___
avrdude-dev mailing list
avrdude-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avrdude-dev