[coreboot-gerrit] Change in coreboot[master]: util/bincfg: don't use fp shared variable
Denis 'GNUtoo' Carikli (Code Review)
gerrit at coreboot.org
Fri Jan 12 07:51:22 CET 2018
Denis 'GNUtoo' Carikli has uploaded this change for review. ( https://review.coreboot.org/23241
Change subject: util/bincfg: don't use fp shared variable
......................................................................
util/bincfg: don't use fp shared variable
Change-Id: Ie710f8c6c06332830c3edb9e5490d1e4877ee33b
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at no-log.org>
---
M util/bincfg/bincfg.y
1 file changed, 18 insertions(+), 16 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/23241/1
diff --git a/util/bincfg/bincfg.y b/util/bincfg/bincfg.y
index 28feb59..0e0d76e 100644
--- a/util/bincfg/bincfg.y
+++ b/util/bincfg/bincfg.y
@@ -20,7 +20,7 @@
#include <string.h>
//#define YYDEBUG 1
int yylex (void);
-void yyerror (char const *);
+void yyerror (FILE* fp, char const *);
struct field {
char *name;
@@ -240,7 +240,7 @@
}
/* {}%BIN -> {} */
-static void generate_setter_bitfields(unsigned char *bin)
+static void generate_setter_bitfields(FILE* fp, unsigned char *bin)
{
unsigned int i;
struct field *ptr;
@@ -265,7 +265,7 @@
fprintf (fp, "\n}\n");
}
-static void generate_binary_with_gbe_checksum(void)
+static void generate_binary_with_gbe_checksum(FILE* fp)
{
int i;
unsigned short checksum;
@@ -337,7 +337,7 @@
}
/* {}{} -> BIN */
-static void generate_binary(void)
+static void generate_binary(FILE* fp)
{
unsigned int i;
struct field *ptr;
@@ -349,7 +349,7 @@
}
if (getsym ("checksum_gbe")) {
- generate_binary_with_gbe_checksum();
+ generate_binary_with_gbe_checksum(fp);
return;
}
@@ -385,6 +385,7 @@
unsigned char u8;
unsigned char *u8array;
}
+%parse-param {FILE* fp}
%token <str> name
%token <u32> val
@@ -409,7 +410,7 @@
;
blob:
- '%' eof { generate_setter_bitfields(
+ '%' eof { generate_setter_bitfields(fp,
binary->actualblob); }
;
@@ -432,7 +433,7 @@
setter:
'{' '}' { fprintf (stderr, "No values\n"); }
| '{' valuemembers '}' { fprintf (stderr, "Parsed all values\n");
- generate_binary(); }
+ generate_binary(fp); }
;
valuemembers:
@@ -448,7 +449,7 @@
%%
/* Called by yyparse on error. */
-void yyerror (char const *s)
+void yyerror (FILE* fp, char const *s)
{
fprintf (stderr, "yyerror: %s\n", s);
}
@@ -457,12 +458,12 @@
void set_input_string(char* in);
/* This function parses a string */
-static int parse_string(unsigned char* in) {
+static int parse_string(FILE* fp, unsigned char* in) {
set_input_string ((char *)in);
- return yyparse ();
+ return yyparse (fp);
}
-static unsigned int loadfile (char *file, char *filetype,
+static unsigned int loadfile (FILE* fp, char *file, char *filetype,
unsigned char **parsestring, unsigned int lenstr)
{
unsigned int lenfile;
@@ -494,6 +495,7 @@
unsigned char c;
unsigned int pos = 0;
int ret = 0;
+ FILE* fp;
#if YYDEBUG == 1
yydebug = 1;
@@ -505,8 +507,8 @@
/* Compile mode */
/* Load Spec */
- lenspec = loadfile(argv[1], "spec", &parsestring, 0);
- loadfile(argv[2], "setter", &parsestring, lenspec);
+ lenspec = loadfile(fp, argv[1], "spec", &parsestring, 0);
+ loadfile(fp, argv[2], "setter", &parsestring, lenspec);
/* Open output and parse string - output to fp */
if ((fp = fopen(argv[3], "wb")) == NULL) {
@@ -514,13 +516,13 @@
argv[3]);
exit(1);
}
- ret = parse_string(parsestring);
+ ret = parse_string(fp, parsestring);
free(parsestring);
} else if (argc == 5 && strcmp (argv[1], "-d") == 0) {
/* Decompile mode */
/* Load Spec */
- lenspec = loadfile(argv[2], "spec", &parsestring, 0);
+ lenspec = loadfile(fp, argv[2], "spec", &parsestring, 0);
parsestring[lenspec] = '%';
parsestring[lenspec + 1] = '\0';
@@ -546,7 +548,7 @@
argv[4]);
exit(1);
}
- ret = parse_string(parsestring);
+ ret = parse_string(fp, parsestring);
free(parsestring);
free(binary->actualblob);
fclose(fp);
--
To view, visit https://review.coreboot.org/23241
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie710f8c6c06332830c3edb9e5490d1e4877ee33b
Gerrit-Change-Number: 23241
Gerrit-PatchSet: 1
Gerrit-Owner: Denis 'GNUtoo' Carikli <GNUtoo at no-log.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180112/8bf1a071/attachment.html>
More information about the coreboot-gerrit
mailing list