LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* resource_size_t printk whinging
@ 2007-02-27  4:16 Kyle McMartin
  2007-02-27 11:02 ` Geert Uytterhoeven
  2007-02-27 17:42 ` H. Peter Anvin
  0 siblings, 2 replies; 6+ messages in thread
From: Kyle McMartin @ 2007-02-27  4:16 UTC (permalink / raw)
  To: linux-kernel

I submitted this patch a while ago, but nobody commented on it.
All these casts of resource_size_t to (unsigned long long) seem horribly
wasteful to me...

Of course, to add a new format qualifier, we lose out on checking the format
string by gcc... Nowadays, this role can be done by sparse.

(Or perhaps gcc can be extended such that a string of allowable qualifiers
 can be passed along in kernel.h, that would just be super...)

This is mostly just to provoke a little bit of further discussion.

Signed-off-by-but-not-really-much-point: Kyle McMartin
	<kyle@parisc-linux.org>

---
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 9ddf25c..a79985d 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -107,25 +107,16 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int);
 extern long simple_strtol(const char *,char **,unsigned int);
 extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
 extern long long simple_strtoll(const char *,char **,unsigned int);
-extern int sprintf(char * buf, const char * fmt, ...)
-	__attribute__ ((format (printf, 2, 3)));
-extern int vsprintf(char *buf, const char *, va_list)
-	__attribute__ ((format (printf, 2, 0)));
-extern int snprintf(char * buf, size_t size, const char * fmt, ...)
-	__attribute__ ((format (printf, 3, 4)));
-extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
-	__attribute__ ((format (printf, 3, 0)));
-extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
-	__attribute__ ((format (printf, 3, 4)));
-extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
-	__attribute__ ((format (printf, 3, 0)));
-extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
-	__attribute__ ((format (printf, 2, 3)));
-
-extern int sscanf(const char *, const char *, ...)
-	__attribute__ ((format (scanf, 2, 3)));
-extern int vsscanf(const char *, const char *, va_list)
-	__attribute__ ((format (scanf, 2, 0)));
+extern int sprintf(char * buf, const char * fmt, ...);
+extern int vsprintf(char *buf, const char *, va_list);
+extern int snprintf(char * buf, size_t size, const char * fmt, ...);
+extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
+extern int scnprintf(char * buf, size_t size, const char * fmt, ...);
+extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
+extern char *kasprintf(gfp_t gfp, const char *fmt, ...);
+
+extern int sscanf(const char *, const char *, ...);
+extern int vsscanf(const char *, const char *, va_list);
 
 extern int get_option(char **str, int *pint);
 extern char *get_options(const char *str, int nints, int *ints);
@@ -140,16 +131,12 @@ extern struct pid *session_of_pgrp(struct pid *pgrp);
 extern void dump_thread(struct pt_regs *regs, struct user *dump);
 
 #ifdef CONFIG_PRINTK
-asmlinkage int vprintk(const char *fmt, va_list args)
-	__attribute__ ((format (printf, 1, 0)));
-asmlinkage int printk(const char * fmt, ...)
-	__attribute__ ((format (printf, 1, 2)));
+asmlinkage int vprintk(const char *fmt, va_list args);
+asmlinkage int printk(const char * fmt, ...);
 #else
-static inline int vprintk(const char *s, va_list args)
-	__attribute__ ((format (printf, 1, 0)));
+static inline int vprintk(const char *s, va_list args);
 static inline int vprintk(const char *s, va_list args) { return 0; }
-static inline int printk(const char *s, ...)
-	__attribute__ ((format (printf, 1, 2)));
+static inline int printk(const char *s, ...);
 static inline int printk(const char *s, ...) { return 0; }
 #endif
 
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index b025864..7a0fd29 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -343,7 +343,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 		/* get the conversion qualifier */
 		qualifier = -1;
 		if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
-		    *fmt =='Z' || *fmt == 'z' || *fmt == 't') {
+		    *fmt == 'Z' || *fmt == 'z' || *fmt == 't' ||
+		    *fmt == 'r' || *fmt == 'R') {
 			qualifier = *fmt;
 			++fmt;
 			if (qualifier == 'l' && *fmt == 'l') {
@@ -477,6 +478,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 			num = (unsigned short) va_arg(args, int);
 			if (flags & SIGN)
 				num = (signed short) num;
+		} else if (qualifier == 'R' || qualifier == 'R') {
+			num = va_arg(args, resource_size_t);
 		} else {
 			num = va_arg(args, unsigned int);
 			if (flags & SIGN)

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

* Re: resource_size_t printk whinging
  2007-02-27  4:16 resource_size_t printk whinging Kyle McMartin
@ 2007-02-27 11:02 ` Geert Uytterhoeven
  2007-02-27 13:15   ` Kyle McMartin
  2007-02-27 17:42 ` H. Peter Anvin
  1 sibling, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2007-02-27 11:02 UTC (permalink / raw)
  To: Kyle McMartin; +Cc: Linux Kernel Development

On Mon, 26 Feb 2007, Kyle McMartin wrote:
> I submitted this patch a while ago, but nobody commented on it.
> All these casts of resource_size_t to (unsigned long long) seem horribly
> wasteful to me...
> 
> Of course, to add a new format qualifier, we lose out on checking the format
> string by gcc... Nowadays, this role can be done by sparse.

But we don't run sparse on every build. We do run gcc (a lot).

> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -477,6 +478,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
>  			num = (unsigned short) va_arg(args, int);
>  			if (flags & SIGN)
>  				num = (signed short) num;
> +		} else if (qualifier == 'R' || qualifier == 'R') {
                                         ^                   ^
One of them must be lowercase `r'.

> +			num = va_arg(args, resource_size_t);
>  		} else {
>  			num = va_arg(args, unsigned int);
>  			if (flags & SIGN)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* Re: resource_size_t printk whinging
  2007-02-27 11:02 ` Geert Uytterhoeven
@ 2007-02-27 13:15   ` Kyle McMartin
  2007-02-27 15:07     ` Tilman Schmidt
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle McMartin @ 2007-02-27 13:15 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Kyle McMartin, Linux Kernel Development

On Tue, Feb 27, 2007 at 12:02:50PM +0100, Geert Uytterhoeven wrote:
> But we don't run sparse on every build. We do run gcc (a lot).
> 

We probably could, in theory...

> > --- a/lib/vsprintf.c
> > +++ b/lib/vsprintf.c
> > @@ -477,6 +478,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
> >  			num = (unsigned short) va_arg(args, int);
> >  			if (flags & SIGN)
> >  				num = (signed short) num;
> > +		} else if (qualifier == 'R' || qualifier == 'R') {
>                                          ^                   ^
> One of them must be lowercase `r'.
> 

Duh. I'm a muppet.

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

* Re: resource_size_t printk whinging
  2007-02-27 13:15   ` Kyle McMartin
@ 2007-02-27 15:07     ` Tilman Schmidt
  2007-02-27 19:39       ` Alexey Dobriyan
  0 siblings, 1 reply; 6+ messages in thread
From: Tilman Schmidt @ 2007-02-27 15:07 UTC (permalink / raw)
  To: Kyle McMartin; +Cc: Geert Uytterhoeven, Linux Kernel Development

[-- Attachment #1: Type: text/plain, Size: 590 bytes --]

Kyle McMartin schrieb:
> On Tue, Feb 27, 2007 at 12:02:50PM +0100, Geert Uytterhoeven wrote:
>> But we don't run sparse on every build. We do run gcc (a lot).
> 
> We probably could, in theory...

Not usefully. I try it occasionally, but there's way too much spewage,
in particular of the "symbol was not declared. Should it be static?"
and "symbol shadows an earlier one" varieties.

-- 
Tilman Schmidt                    E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

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

* Re: resource_size_t printk whinging
  2007-02-27  4:16 resource_size_t printk whinging Kyle McMartin
  2007-02-27 11:02 ` Geert Uytterhoeven
@ 2007-02-27 17:42 ` H. Peter Anvin
  1 sibling, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2007-02-27 17:42 UTC (permalink / raw)
  To: Kyle McMartin; +Cc: linux-kernel

Kyle McMartin wrote:
> 
> (Or perhaps gcc can be extended such that a string of allowable qualifiers
>  can be passed along in kernel.h, that would just be super...)
> 

That would of course be the best.  Something like an 
"format_custom_size("r", resource_t)" attribute.

	-hpa

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

* Re: resource_size_t printk whinging
  2007-02-27 15:07     ` Tilman Schmidt
@ 2007-02-27 19:39       ` Alexey Dobriyan
  0 siblings, 0 replies; 6+ messages in thread
From: Alexey Dobriyan @ 2007-02-27 19:39 UTC (permalink / raw)
  To: Tilman Schmidt
  Cc: Kyle McMartin, Geert Uytterhoeven, Linux Kernel Development

On Tue, Feb 27, 2007 at 04:07:00PM +0100, Tilman Schmidt wrote:
> Kyle McMartin schrieb:
> > On Tue, Feb 27, 2007 at 12:02:50PM +0100, Geert Uytterhoeven wrote:
> >> But we don't run sparse on every build. We do run gcc (a lot).
> > 
> > We probably could, in theory...
> 
> Not usefully. I try it occasionally, but there's way too much spewage,
> in particular of the "symbol was not declared. Should it be static?"
> and "symbol shadows an earlier one" varieties.

	make C=2 CF="-Wno-decl -Wno-shadow [-Wno-context]"


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

end of thread, other threads:[~2007-02-27 19:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-27  4:16 resource_size_t printk whinging Kyle McMartin
2007-02-27 11:02 ` Geert Uytterhoeven
2007-02-27 13:15   ` Kyle McMartin
2007-02-27 15:07     ` Tilman Schmidt
2007-02-27 19:39       ` Alexey Dobriyan
2007-02-27 17:42 ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).