[PATCH 2/6] nios2gen: Fix warnings

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jun 7 05:39:03 UTC 2018


Update #3444.
---
 misc/nios2gen/bridges.c  |  5 ++---
 misc/nios2gen/clocks.c   |  5 ++---
 misc/nios2gen/devices.c  |  4 ++--
 misc/nios2gen/linkcmds.c | 14 ++++++--------
 misc/nios2gen/memory.c   |  4 +---
 misc/nios2gen/nios2gen.c | 12 ++++++------
 misc/nios2gen/output.c   |  6 +++---
 misc/nios2gen/ptf.c      |  4 +---
 8 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/misc/nios2gen/bridges.c b/misc/nios2gen/bridges.c
index feb90f9..cfd43d3 100644
--- a/misc/nios2gen/bridges.c
+++ b/misc/nios2gen/bridges.c
@@ -38,7 +38,6 @@ int is_bridged(
   char *dev_master,
   bus_bridge_pair *bridges)
 {
-  char *curr_master;
   bus_bridge_pair *bbp;
 
   if(strcmp(cpu_master, dev_master) == 0) return 1; /* cpu directly masters dev */
@@ -74,7 +73,7 @@ void add_bridge_master(struct ptf_item *pi, void *arg)
 void add_bridge_dest(struct ptf_item *pi, void *arg)
 {
     struct ptf maby_section = { section, "MASTERED_BY", 0, 0, 0 };
-    struct ptf_item maby = { 1, &maby_section };
+    struct ptf_item maby = { 1, { &maby_section } };
 
     char *bridge_name = pi->item[1]->value;
     char *bridge_dest = pi->item[pi->level]->value;
@@ -100,7 +99,7 @@ bus_bridge_pair *find_bridges(struct ptf *p)
     struct ptf slave      = { section, "SLAVE",  0, 0, 0 };
     struct ptf syb        = { section, "SYSTEM_BUILDER_INFO", 0, 0, 0 };
     struct ptf to         = { item,    "Bridges_To", 0, 0, 0 };
-    struct ptf_item brdg  = { 5, &system, &module, &slave, &syb, &to };
+    struct ptf_item brdg  = { 5, { &system, &module, &slave, &syb, &to } };
 
     ptf_match(p, &brdg, add_bridge_dest, &bridges);
 
diff --git a/misc/nios2gen/clocks.c b/misc/nios2gen/clocks.c
index cb2befa..2b38e3f 100644
--- a/misc/nios2gen/clocks.c
+++ b/misc/nios2gen/clocks.c
@@ -15,7 +15,6 @@ void add_clock_spec(struct ptf_item *pi, void *arg)
 {
   clock_desc **clocks = arg;
   clock_desc *new_clock;
-  unsigned long freq;
 
   new_clock = (clock_desc*)malloc(sizeof(clock_desc));
   if(new_clock == NULL) return;
@@ -45,10 +44,10 @@ clock_desc *find_clocks( struct ptf *sopc, struct ptf *cfg )
     struct ptf all           = { section, "CLOCKS", 0, 0, 0 };
     struct ptf clock         = { section, "CLOCK", 0, 0, 0 };
     struct ptf freq          = { item,    "frequency", 0, 0, 0 };
-    struct ptf_item clk_spec = { 5, &system, &wizargs, &all, &clock, &freq };
+    struct ptf_item clk_spec = { 5, { &system, &wizargs, &all, &clock, &freq } };
 
     struct ptf named     = { item, 0, 0, 0, 0 };
-    struct ptf_item clk_cfg = { 2, &all, &named };
+    struct ptf_item clk_cfg = { 2, { &all, &named } };
 
     clocks = NULL;
     ptf_match(sopc, &clk_spec, add_clock_spec, &clocks);
diff --git a/misc/nios2gen/devices.c b/misc/nios2gen/devices.c
index 7894294..037c987 100644
--- a/misc/nios2gen/devices.c
+++ b/misc/nios2gen/devices.c
@@ -73,11 +73,11 @@ device_desc *find_devices(
     struct ptf slave      = { section, "SLAVE",  0, 0, 0 };
     struct ptf syb        = { section, "SYSTEM_BUILDER_INFO", 0, 0, 0 };
     struct ptf maby       = { section, "MASTERED_BY", 0, 0, 0 };
-    struct ptf_item brdg  = { 5, &system, &module, &slave, &syb, &maby };
+    struct ptf_item brdg  = { 5, { &system, &module, &slave, &syb, &maby } };
 
     struct ptf modules    = { section, "MODULES", 0, 0, 0 };
     struct ptf named      = { item, 0, 0, 0, 0};
-    struct ptf_item devcf = { 2, &modules, &named };
+    struct ptf_item devcf = { 2, { &modules, &named } };
 
     struct { char *dm; char *im; device_desc **dl; bus_bridge_pair *bridges; } dinfo;
 
diff --git a/misc/nios2gen/linkcmds.c b/misc/nios2gen/linkcmds.c
index 8ed0ddb..3a56165 100644
--- a/misc/nios2gen/linkcmds.c
+++ b/misc/nios2gen/linkcmds.c
@@ -71,22 +71,20 @@ void fwrite_lcmds_section(struct ptf_item *pi, void *arg)
 
 void fwrite_linkcmds_file(FILE *file, struct ptf *cfg, struct ptf *cpu, device_desc *devices, memory_desc *memory)
 {
-  struct ptf *p;
-  struct ptf_item pi;
   memory_desc *tmd;
   lcmd_desc linfo;
 
   struct ptf ptlink = { section, "LINKCMDS", 0, 0, 0 };
   struct ptf ptleadtext = { item,    "LEADTEXT", 0, 0, 0 };
   struct ptf ptepilog = { item,    "EPILOG", 0, 0, 0 };
-  struct ptf_item malihead = { 2, &ptlink, &ptleadtext };
-  struct ptf_item maliepil = { 2, &ptlink, &ptepilog };
+  struct ptf_item malihead = { 2, { &ptlink, &ptleadtext } };
+  struct ptf_item maliepil = { 2, { &ptlink, &ptepilog } };
 
   struct ptf ptsect = { section, "SECTION", 0, 0, 0 };
   struct ptf ptcmds = { item, "COMMANDS", 0, 0, 0 };
   struct ptf ptstabs = { item, "STABS", 0, 0, 0 };
-  struct ptf_item malisect = { 3, &ptlink, &ptsect, &ptcmds };
-  struct ptf_item malistabs = { 2, &ptlink, &ptstabs };
+  struct ptf_item malisect = { 3, { &ptlink, &ptsect, &ptcmds } };
+  struct ptf_item malistabs = { 2, { &ptlink, &ptstabs } };
 
   linfo.cfg     = cfg;
   linfo.cpu     = cpu;
@@ -99,7 +97,7 @@ void fwrite_linkcmds_file(FILE *file, struct ptf *cfg, struct ptf *cpu, device_d
   fprintf(file, "MEMORY\n{\n");
   for(tmd = linfo.memory; tmd; tmd = tmd->next)
   {
-    fprintf(file, "    %s : ORIGIN = 0x%08X, LENGTH = 0x%08X\n", tmd->dev->cfgname, tmd->base, tmd->size);
+    fprintf(file, "    %s : ORIGIN = 0x%08lX, LENGTH = 0x%08lX\n", tmd->dev->cfgname, tmd->base, tmd->size);
   }
   fprintf(file, "}\n\nSECTIONS\n{\n");
 
@@ -108,7 +106,7 @@ void fwrite_linkcmds_file(FILE *file, struct ptf *cfg, struct ptf *cpu, device_d
 
   for(tmd = linfo.memory; tmd; tmd = tmd->next)
   {
-    fprintf(file, "    %s : ORIGIN = 0x%08X, LENGTH = 0x%08X\n", tmd->dev->cfgname, tmd->base, tmd->size);
+    fprintf(file, "    %s : ORIGIN = 0x%08lX, LENGTH = 0x%08lX\n", tmd->dev->cfgname, tmd->base, tmd->size);
   }
 
 
diff --git a/misc/nios2gen/memory.c b/misc/nios2gen/memory.c
index cb1ea7f..4ba6b70 100644
--- a/misc/nios2gen/memory.c
+++ b/misc/nios2gen/memory.c
@@ -16,8 +16,6 @@
 
 memory_desc *find_memory(device_desc *devices)
 {
-  struct ptf *p;
-  struct ptf_item pi;
   memory_desc *tmd;
   memory_desc *memory = NULL;
 
@@ -26,7 +24,7 @@ memory_desc *find_memory(device_desc *devices)
 
   if(devices)
   {
-    struct ptf *p, *s;
+    struct ptf *p, *s = NULL;
     struct ptf_item pi;
     device_desc *dd;
 
diff --git a/misc/nios2gen/nios2gen.c b/misc/nios2gen/nios2gen.c
index 688038a..e91f201 100644
--- a/misc/nios2gen/nios2gen.c
+++ b/misc/nios2gen/nios2gen.c
@@ -53,6 +53,7 @@ void read_include_file(struct ptf_item *pi, void *arg)
     struct ptf *inc, *next;
     struct ptf *p = pi->item[pi->level];
 
+    (void)arg;
     inc = ptf_parse_file(p->value);
 
     if(inc == NULL)
@@ -104,8 +105,7 @@ void usage (FILE *f, char *errmsg)
 
 int main(int argc, char *argv[])
 {
-    struct ptf *sopc, *cfg, *p, *cpu;
-    struct ptf_item pi;
+    struct ptf *sopc, *cfg, *cpu;
     device_desc *devices;
     bus_bridge_pair *bridges;
     clock_desc *clocks;
@@ -250,7 +250,7 @@ int main(int argc, char *argv[])
 
     {
       struct ptf include_item = { item, "INCLUDE", 0, 0, 0 };
-      struct ptf_item inc_file_spec = { 1, &include_item };
+      struct ptf_item inc_file_spec = { 1, { &include_item } };
       ptf_match(cfg, &inc_file_spec, read_include_file, NULL);
     }
 
@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
     {
       struct ptf modules         = { section, "MODULES", 0, 0, 0 };
       struct ptf cpu_def         = { item, "CPU", 0, 0, 0 };
-      struct ptf_item cpu_spec   = { 2, &modules, &cpu_def };
+      struct ptf_item cpu_spec   = { 2, { &modules, &cpu_def } };
 
       ptf_match(cfg, &cpu_spec, store_ptf_ptr, &cpu);
     };
@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
       struct ptf system          = { section, "SYSTEM", 0, 0, 0 };
       struct ptf module          = { section, "MODULE", 0, 0, 0 };
       struct ptf nios2_cpu_class = { item, "class", "altera_nios2", 0, 0 };
-      struct ptf_item class_spec = { 3, &system, &module, &nios2_cpu_class };
+      struct ptf_item class_spec = { 3, { &system, &module, &nios2_cpu_class } };
 
       if(cpu) if(cpu->value) class_spec.item[1]->value = cpu->value;
 
@@ -386,7 +386,7 @@ int main(int argc, char *argv[])
         memory_desc *md;
         for(md = memory; md; md=md->next)
         {
-          printf("Found memory in \"%s\", base=0x%08X, size=%lu bytes\n",
+          printf("Found memory in \"%s\", base=0x%08lX, size=%lu bytes\n",
                           md->dev->cfgname,
                           md->base, md->size);
         };
diff --git a/misc/nios2gen/output.c b/misc/nios2gen/output.c
index 088ebe8..a45d796 100644
--- a/misc/nios2gen/output.c
+++ b/misc/nios2gen/output.c
@@ -146,14 +146,14 @@ void fwrite_header_file( FILE *file, struct ptf *cfg, device_desc *devices, cloc
   struct ptf_item pi;
 
   struct ptf aclass = { section, "CLASS", 0, 0, 0 };
-  struct ptf_item matchaclass = { 1, &aclass };
+  struct ptf_item matchaclass = { 1, { &aclass } };
 
   struct ptf bspsect = { section, "BSPHEADER", 0, 0, 0 };
   struct ptf leadtext = { item, "LEADTEXT", 0, 0, 0 };
-  struct ptf_item matchleadtext = { 2, &bspsect, &leadtext };
+  struct ptf_item matchleadtext = { 2, { &bspsect, &leadtext } };
 
   struct ptf epilog = { item, "EPILOG", 0, 0, 0 };
-  struct ptf_item matchepilog = { 2, &bspsect, &epilog };
+  struct ptf_item matchepilog = { 2, { &bspsect, &epilog } };
 
   out_desc dinfo;
 
diff --git a/misc/nios2gen/ptf.c b/misc/nios2gen/ptf.c
index 07d6183..f7e83f0 100644
--- a/misc/nios2gen/ptf.c
+++ b/misc/nios2gen/ptf.c
@@ -457,7 +457,6 @@ struct ptf *ptf_parse_file(char *filename)
   FILE *f;
   char buffer[1024];
 
-  struct ptf *root;
   struct ptf_parser_state state;
 
   if(filename == NULL)
@@ -528,7 +527,7 @@ struct ptf *ptf_concat(struct ptf *a, struct ptf *b)
 void ptf_dump_ptf_item(FILE *f, struct ptf_item *pi)
 {
   int i;
-  fprintf(f, "level=%d in %p\n", pi->level, pi);
+  fprintf(f, "level=%d in %p\n", pi->level, (void *)pi);
   for(i=pi->level;i>=0;i--)
   {
     if(pi->item[i] != NULL)
@@ -746,7 +745,6 @@ struct ptf *ptf_next(
   char *value)
 {
   int r;
-  struct ptf *leaf;
 
   if(item == NULL) { errno = EINVAL; return NULL; };
 
-- 
2.13.7




More information about the devel mailing list