mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t
@ 2020-02-18 14:16 Ahmad Fatoum
  2020-02-18 14:16 ` [PATCH 2/3] scripts: define ALIGN(x) in scripts' <linux/kernel.h> Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-02-18 14:16 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

C99 specifies the 't' length modifier type for pointer difference.
barebox vsnprintf supports it, thus use it.

We are guaranteed sizeof(long) == sizeof(void *) in barebox, so this
doesn't make a difference in practice except that it silences
following GCC warning:

  ./drivers/gpio/gpiolib.c: In function 'gpioinfo_request':
  ./include/printk.h:77:43: warning: format '%ld' expects argument of
     type 'long int', but argument 3 has type 'int' [-Wformat=]
  ...
  ./barebox-stm32/drivers/gpio/gpiolib.c:89:3: note: in expansion of macro 'pr_err'
     89 |   pr_err("_gpio_request: gpio-%ld (%s) status %d\n",

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index cfa77360b3d2..27674af54caa 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -86,7 +86,7 @@ static int gpioinfo_request(struct gpio_info *gi, const char *label)
 
 done:
 	if (ret)
-		pr_err("_gpio_request: gpio-%ld (%s) status %d\n",
+		pr_err("_gpio_request: gpio-%td (%s) status %d\n",
 		       gi - gpio_desc, label ? : "?", ret);
 
 	return ret;
-- 
2.25.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] scripts: define ALIGN(x) in scripts' <linux/kernel.h>
  2020-02-18 14:16 [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t Ahmad Fatoum
@ 2020-02-18 14:16 ` Ahmad Fatoum
  2020-02-18 14:16 ` [PATCH 3/3] scripts: imd: remove duplicate macro definitions Ahmad Fatoum
  2020-02-19  7:54 ` [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-02-18 14:16 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

To make code sharing between utilities in scripts/ and barebox easier,
define ALIGN in the scripts/include/linux/kernel.h as well for
compatibility with the barebox include/linux/kernel.h.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/include/linux/kernel.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/include/linux/kernel.h b/scripts/include/linux/kernel.h
index 5d94e984f10b..dc2e64e16413 100644
--- a/scripts/include/linux/kernel.h
+++ b/scripts/include/linux/kernel.h
@@ -6,6 +6,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
+#define __ALIGN_MASK(x, mask)	(((x) + (mask)) & ~(mask))
+#define ALIGN(x, a)		__ALIGN_MASK(x, (typeof(x))(a) - 1)
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
-- 
2.25.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] scripts: imd: remove duplicate macro definitions
  2020-02-18 14:16 [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t Ahmad Fatoum
  2020-02-18 14:16 ` [PATCH 2/3] scripts: define ALIGN(x) in scripts' <linux/kernel.h> Ahmad Fatoum
@ 2020-02-18 14:16 ` Ahmad Fatoum
  2020-02-19  7:54 ` [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-02-18 14:16 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

include/scripts/linux/kernel.h included via #include <linux/kernel.h>
later on already defines these three macros. Remove them here to avoid
the warnings about the duplicate macro definition.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/bareboximd.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/scripts/bareboximd.c b/scripts/bareboximd.c
index cf1b8f693ac0..e5000e0aea5b 100644
--- a/scripts/bareboximd.c
+++ b/scripts/bareboximd.c
@@ -16,10 +16,6 @@
  *
  */
 
-#define __ALIGN_MASK(x, mask)	(((x) + (mask)) & ~(mask))
-#define ALIGN(x, a)		__ALIGN_MASK(x, (typeof(x))(a) - 1)
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
 #include <stdio.h>
 #include <sys/types.h>
 #include <stdint.h>
-- 
2.25.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t
  2020-02-18 14:16 [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t Ahmad Fatoum
  2020-02-18 14:16 ` [PATCH 2/3] scripts: define ALIGN(x) in scripts' <linux/kernel.h> Ahmad Fatoum
  2020-02-18 14:16 ` [PATCH 3/3] scripts: imd: remove duplicate macro definitions Ahmad Fatoum
@ 2020-02-19  7:54 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2020-02-19  7:54 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Tue, Feb 18, 2020 at 03:16:34PM +0100, Ahmad Fatoum wrote:
> C99 specifies the 't' length modifier type for pointer difference.
> barebox vsnprintf supports it, thus use it.
> 
> We are guaranteed sizeof(long) == sizeof(void *) in barebox, so this
> doesn't make a difference in practice except that it silences
> following GCC warning:
> 
>   ./drivers/gpio/gpiolib.c: In function 'gpioinfo_request':
>   ./include/printk.h:77:43: warning: format '%ld' expects argument of
>      type 'long int', but argument 3 has type 'int' [-Wformat=]
>   ...
>   ./barebox-stm32/drivers/gpio/gpiolib.c:89:3: note: in expansion of macro 'pr_err'
>      89 |   pr_err("_gpio_request: gpio-%ld (%s) status %d\n",
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/gpio/gpiolib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-02-19  7:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 14:16 [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t Ahmad Fatoum
2020-02-18 14:16 ` [PATCH 2/3] scripts: define ALIGN(x) in scripts' <linux/kernel.h> Ahmad Fatoum
2020-02-18 14:16 ` [PATCH 3/3] scripts: imd: remove duplicate macro definitions Ahmad Fatoum
2020-02-19  7:54 ` [PATCH 1/3] gpiolib: use correct format specifier for ptrdiff_t Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox