Commit e70d8f55 authored by Mathieu Malaterre's avatar Mathieu Malaterre Committed by Michael Ellerman

powerpc/xmon: Add __printf annotation to xmon_printf()

This allows the compiler to verify the format strings vs the types of
the arguments.

Update the other prototype declarations in asm/xmon.h.

Silence warnings (triggered at W=1) by adding relevant __printf
attribute. Move #define at bottom of the file to prevent conflict with
gcc attribute.

Solves the original warning:

  arch/powerpc/xmon/nonstdio.c:178:2: error: function might be
  possible candidate for ‘gnu_printf’ format attribute

In turn this uncovered many formatting errors in xmon.c, all fixed in
this patch.
Signed-off-by: default avatarMathieu Malaterre <malat@debian.org>
[mpe: Always use px not p, fixup the 44x specific code, tweak change log]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 6671683d
...@@ -29,7 +29,7 @@ static inline void xmon_register_spus(struct list_head *list) { }; ...@@ -29,7 +29,7 @@ static inline void xmon_register_spus(struct list_head *list) { };
extern int cpus_are_in_xmon(void); extern int cpus_are_in_xmon(void);
#endif #endif
extern void xmon_printf(const char *format, ...); extern __printf(1, 2) void xmon_printf(const char *format, ...);
#endif /* __KERNEL __ */ #endif /* __KERNEL __ */
#endif /* __ASM_POWERPC_XMON_H */ #endif /* __ASM_POWERPC_XMON_H */
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
#define EOF (-1) #define EOF (-1)
#define printf xmon_printf
#define putchar xmon_putchar
extern void xmon_set_pagination_lpp(unsigned long lpp); extern void xmon_set_pagination_lpp(unsigned long lpp);
extern void xmon_start_pagination(void); extern void xmon_start_pagination(void);
extern void xmon_end_pagination(void); extern void xmon_end_pagination(void);
extern int xmon_putchar(int c); extern int xmon_putchar(int c);
extern void xmon_puts(const char *); extern void xmon_puts(const char *);
extern char *xmon_gets(char *, int); extern char *xmon_gets(char *, int);
extern void xmon_printf(const char *, ...); extern __printf(1, 2) void xmon_printf(const char *fmt, ...);
#define printf xmon_printf
#define putchar xmon_putchar
...@@ -102,7 +102,7 @@ print_insn_spu (unsigned long insn, unsigned long memaddr) ...@@ -102,7 +102,7 @@ print_insn_spu (unsigned long insn, unsigned long memaddr)
if (index == 0) if (index == 0)
{ {
printf(".long 0x%x", insn); printf(".long 0x%lx", insn);
} }
else else
{ {
...@@ -134,27 +134,27 @@ print_insn_spu (unsigned long insn, unsigned long memaddr) ...@@ -134,27 +134,27 @@ print_insn_spu (unsigned long insn, unsigned long memaddr)
switch (arg) switch (arg)
{ {
case A_T: case A_T:
printf("$%d", printf("$%lu",
DECODE_INSN_RT (insn)); DECODE_INSN_RT (insn));
break; break;
case A_A: case A_A:
printf("$%d", printf("$%lu",
DECODE_INSN_RA (insn)); DECODE_INSN_RA (insn));
break; break;
case A_B: case A_B:
printf("$%d", printf("$%lu",
DECODE_INSN_RB (insn)); DECODE_INSN_RB (insn));
break; break;
case A_C: case A_C:
printf("$%d", printf("$%lu",
DECODE_INSN_RC (insn)); DECODE_INSN_RC (insn));
break; break;
case A_S: case A_S:
printf("$sp%d", printf("$sp%lu",
DECODE_INSN_RA (insn)); DECODE_INSN_RA (insn));
break; break;
case A_H: case A_H:
printf("$ch%d", printf("$ch%lu",
DECODE_INSN_RA (insn)); DECODE_INSN_RA (insn));
break; break;
case A_P: case A_P:
...@@ -162,11 +162,11 @@ print_insn_spu (unsigned long insn, unsigned long memaddr) ...@@ -162,11 +162,11 @@ print_insn_spu (unsigned long insn, unsigned long memaddr)
printf("("); printf("(");
break; break;
case A_U7A: case A_U7A:
printf("%d", printf("%lu",
173 - DECODE_INSN_U8 (insn)); 173 - DECODE_INSN_U8 (insn));
break; break;
case A_U7B: case A_U7B:
printf("%d", printf("%lu",
155 - DECODE_INSN_U8 (insn)); 155 - DECODE_INSN_U8 (insn));
break; break;
case A_S3: case A_S3:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment