* dtc: Make some functions local to parser
@ 2008-03-04 4:37 David Gibson
2008-03-04 19:18 ` Scott Wood
0 siblings, 1 reply; 3+ messages in thread
From: David Gibson @ 2008-03-04 4:37 UTC (permalink / raw)
To: Jon Loeliger; +Cc: linuxppc-dev
* eval_literal() is defined and used only in the parser, so make it
static.
* The Bison documentation explicitly permits yyerror() to be a
variadic function, so fold yyerror() and yyerrorf() into a single
printf-style function. The combined function is defined and used
only in the parse, so make it static.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
dtc-parser.y | 14 +++++---------
srcpos.h | 3 ---
2 files changed, 5 insertions(+), 12 deletions(-)
Index: dtc/dtc-parser.y
===================================================================
--- dtc.orig/dtc-parser.y 2008-03-04 15:29:09.000000000 +1100
+++ dtc/dtc-parser.y 2008-03-04 15:31:32.000000000 +1100
@@ -24,12 +24,13 @@
#include "dtc.h"
#include "srcpos.h"
-int yylex(void);
-unsigned long long eval_literal(const char *s, int base, int bits);
+extern int yylex(void);
extern struct boot_info *the_boot_info;
extern int treesource_error;
+static void yyerror(char const *, ...) __attribute__((format(printf, 1, 2)));
+static unsigned long long eval_literal(const char *s, int base, int bits);
%}
%union {
@@ -308,7 +309,7 @@ label:
%%
-void yyerrorf(char const *s, ...)
+static void yyerror(char const *s, ...)
{
const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
va_list va;
@@ -325,12 +326,7 @@ void yyerrorf(char const *s, ...)
va_end(va);
}
-void yyerror (char const *s)
-{
- yyerrorf("%s", s);
-}
-
-unsigned long long eval_literal(const char *s, int base, int bits)
+static unsigned long long eval_literal(const char *s, int base, int bits)
{
unsigned long long val;
char *e;
Index: dtc/srcpos.h
===================================================================
--- dtc.orig/srcpos.h 2008-03-04 15:30:06.000000000 +1100
+++ dtc/srcpos.h 2008-03-04 15:30:09.000000000 +1100
@@ -70,9 +70,6 @@ typedef struct YYLTYPE {
-extern void yyerror(char const *);
-extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2)));
-
extern struct dtc_file *srcpos_file;
extern void push_input_file(const char *filename);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: dtc: Make some functions local to parser
2008-03-04 4:37 dtc: Make some functions local to parser David Gibson
@ 2008-03-04 19:18 ` Scott Wood
2008-03-05 0:38 ` David Gibson
0 siblings, 1 reply; 3+ messages in thread
From: Scott Wood @ 2008-03-04 19:18 UTC (permalink / raw)
To: Jon Loeliger, linuxppc-dev
On Tue, Mar 04, 2008 at 03:37:00PM +1100, David Gibson wrote:
> * The Bison documentation explicitly permits yyerror() to be a
> variadic function, so fold yyerror() and yyerrorf() into a single
> printf-style function.
Then the bison documentation is not consistent with the bison
implementation when verbose error messages are enabled. How can it possibly
know whether to put % or %% in the string when an unexpected % is
encountered?
Reading bison internals makes my head hurt...
> The combined function is defined and used
> only in the parse, so make it static.
Static-izing something that is used externally in a posted patch where
you've provided no alternate to use is rather bad form...
-Scott
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: dtc: Make some functions local to parser
2008-03-04 19:18 ` Scott Wood
@ 2008-03-05 0:38 ` David Gibson
0 siblings, 0 replies; 3+ messages in thread
From: David Gibson @ 2008-03-05 0:38 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On Tue, Mar 04, 2008 at 01:18:44PM -0600, Scott Wood wrote:
> On Tue, Mar 04, 2008 at 03:37:00PM +1100, David Gibson wrote:
> > * The Bison documentation explicitly permits yyerror() to be a
> > variadic function, so fold yyerror() and yyerrorf() into a single
> > printf-style function.
>
> Then the bison documentation is not consistent with the bison
> implementation when verbose error messages are enabled. How can it possibly
> know whether to put % or %% in the string when an unexpected % is
> encountered?
Ah crap. I'd forgotten the specific case you mentioned before.
> Reading bison internals makes my head hurt...
>
> > The combined function is defined and used
> > only in the parse, so make it static.
>
> Static-izing something that is used externally in a posted patch where
> you've provided no alternate to use is rather bad form...
IIRC, I already asked you *not* to use it externally, though. And a
lot of these patches I've been posting lately are yak-shaving leading
up to a generally available error function.
Still, forget this patch for now.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-03-05 0:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-04 4:37 dtc: Make some functions local to parser David Gibson
2008-03-04 19:18 ` Scott Wood
2008-03-05 0:38 ` David Gibson
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).