diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-11-16 16:57:00 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-01-21 15:24:50 +1100 |
commit | 3ee7ca100e2068d69b750d77568957efffe7178f (patch) | |
tree | f532f4c303261dbf2675a7b1f4ee59408ddec58f | |
parent | 5df1dcbd4acbdaeeaa923882867b02179dfb6bc7 (diff) | |
download | skiboot-3ee7ca100e2068d69b750d77568957efffe7178f.zip skiboot-3ee7ca100e2068d69b750d77568957efffe7178f.tar.gz skiboot-3ee7ca100e2068d69b750d77568957efffe7178f.tar.bz2 |
Enable -Werror for -Wformat
commit 56bc1890b229072513788992d1d29b6f173c13de upstream
We create our own inttypes.h to get the correct printf formatting for
64bit numbers.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | Makefile.main | 2 | ||||
-rw-r--r-- | core/mem_region.c | 8 | ||||
-rw-r--r-- | core/test/run-mem_range_is_reserved.c | 2 | ||||
-rw-r--r-- | hdata/iohub.c | 21 | ||||
-rw-r--r-- | hdata/vpd.c | 3 | ||||
-rw-r--r-- | include/inttypes.h | 44 |
6 files changed, 64 insertions, 16 deletions
diff --git a/Makefile.main b/Makefile.main index c0f0955..34591be 100644 --- a/Makefile.main +++ b/Makefile.main @@ -28,7 +28,7 @@ CWARNS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Wwrite-strings -Wcast-align \ -Winit-self \ -Wframe-larger-than=1024 \ - -Werror -Wno-error=format + -Werror # Host tools and options HOSTCC=gcc diff --git a/core/mem_region.c b/core/mem_region.c index f8d9a11..40b486b 100644 --- a/core/mem_region.c +++ b/core/mem_region.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <inttypes.h> #include <skiboot.h> #include <mem-map.h> #include <libfdt_env.h> @@ -320,11 +321,12 @@ int64_t mem_dump_free(void) region_free+= hdr->num_longs * sizeof(long); } - printf("Region %s free: %llu\n", region->name, region_free); + printf("Region %s free: %"PRIx64"\n", + region->name, region_free); total_free += region_free; } - printf("Total free: %llu\n", total_free); + printf("Total free: %"PRIu64"\n", total_free); return total_free; } @@ -686,7 +688,7 @@ static bool add_region(struct mem_region *region) struct mem_region *r; if (mem_regions_finalised) { - prerror("MEM: add_region(%s@0x%llx) called after finalise!\n", + prerror("MEM: add_region(%s@0x%"PRIx64") called after finalise!\n", region->name, region->start); return false; } diff --git a/core/test/run-mem_range_is_reserved.c b/core/test/run-mem_range_is_reserved.c index b504326..0efe9b9 100644 --- a/core/test/run-mem_range_is_reserved.c +++ b/core/test/run-mem_range_is_reserved.c @@ -178,7 +178,7 @@ static void run_test(struct test *test) fprintf(stderr, "reserved regions:\n"); list_for_each(®ions, r, list) { - fprintf(stderr, "\t: %08x[%08x] %s\n", + fprintf(stderr, "\t: %08"PRIx64"[%08"PRIx64"] %s\n", r->start, r->len, r->name); } exit(EXIT_FAILURE); diff --git a/hdata/iohub.c b/hdata/iohub.c index d189cb7..44ebded 100644 --- a/hdata/iohub.c +++ b/hdata/iohub.c @@ -25,6 +25,7 @@ #include <p5ioc2.h> #include <p7ioc.h> #include <vpd.h> +#include <inttypes.h> #include "hdata.h" @@ -142,15 +143,15 @@ static struct dt_node *io_add_p5ioc2(const struct cechub_io_hub *hub, prlog(PR_DEBUG, " GX#%d BUID_Ext = 0x%x\n", be32_to_cpu(hub->gx_index), be32_to_cpu(hub->buid_ext)); - prlog(PR_DEBUG, " GX BAR 0 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 0 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar0)); - prlog(PR_DEBUG, " GX BAR 1 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 1 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar1)); - prlog(PR_DEBUG, " GX BAR 2 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 2 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar2)); - prlog(PR_DEBUG, " GX BAR 3 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 3 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar3)); - prlog(PR_DEBUG, " GX BAR 4 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 4 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar4)); /* We assume SBAR == GX0 + some hard coded offset */ @@ -194,15 +195,15 @@ static struct dt_node *io_add_p7ioc(const struct cechub_io_hub *hub, prlog(PR_DEBUG, " GX#%d BUID_Ext = 0x%x\n", be32_to_cpu(hub->gx_index), be32_to_cpu(hub->buid_ext)); - prlog(PR_DEBUG, " GX BAR 0 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 0 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar0)); - prlog(PR_DEBUG, " GX BAR 1 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 1 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar1)); - prlog(PR_DEBUG, " GX BAR 2 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 2 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar2)); - prlog(PR_DEBUG, " GX BAR 3 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 3 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar3)); - prlog(PR_DEBUG, " GX BAR 4 = 0x%016llx\n", + prlog(PR_DEBUG, " GX BAR 4 = 0x%016"PRIx64"\n", be64_to_cpu(hub->gx_ctrl_bar4)); /* We only know about memory map 1 */ diff --git a/hdata/vpd.c b/hdata/vpd.c index 585ed9c..754e5f6 100644 --- a/hdata/vpd.c +++ b/hdata/vpd.c @@ -21,6 +21,7 @@ #include "hdata.h" #include <device.h> #include "hdata.h" +#include <inttypes.h> struct card_info { const char *ccin; /* Customer card identification number */ @@ -502,7 +503,7 @@ static struct dt_node *dt_create_vpd_node(struct dt_node *parent, addr = (uint64_t)be16_to_cpu(entry->rsrc_id); node = dt_new_addr(parent, name, addr); if (!node) { - prerror("VPD: Creating node at %s@%llx failed\n", name, addr); + prerror("VPD: Creating node at %s@%"PRIx64" failed\n", name, addr); return NULL; } diff --git a/include/inttypes.h b/include/inttypes.h new file mode 100644 index 0000000..8e640ca --- /dev/null +++ b/include/inttypes.h @@ -0,0 +1,44 @@ +/* Copyright 2015 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This file exists because a bunch of files are built as part of + * unit tests as well as skiboot and inttypes.h is part of libc rather + * than gcc, so to get the magic to work when we don't have libc sitting + * around, we get to rewrite inttypes.h. + */ + +#ifndef __SKIBOOT_INTTYPES_H +#define __SKIBOOT_INTTYPES_H + +#include <stdint.h> + +#ifndef __WORDSIZE +/* If we don't have __WORDSIZE it means we're *certainly* building skiboot + * which will *ALWAYS* have a word size of 32bits. + * (unless someone goes and ports skiboot to something that isn't powerpc) + */ +#define __WORDSIZE 32 +#endif + +#if __WORDSIZE == 64 +#define PRIu64 "lu" +#define PRIx64 "lx" +#else +#define PRIu64 "llu" +#define PRIx64 "llx" +#endif + +#endif |