diff options
author | Alistair Popple <alistair@popple.id.au> | 2017-07-14 14:51:11 +1000 |
---|---|---|
committer | Alistair Popple <alistair@popple.id.au> | 2017-07-14 14:56:32 +1000 |
commit | 7754a6ebe08a5b4863fe24bdbfbb6fc9e15dd561 (patch) | |
tree | 1059647d639409915512d2aaf5a74e379bbe2f53 /libpdbg | |
parent | 62ddc2bfa872aeaae3bf07e8ac1d9e6b028c87ce (diff) | |
download | pdbg-7754a6ebe08a5b4863fe24bdbfbb6fc9e15dd561.tar.gz pdbg-7754a6ebe08a5b4863fe24bdbfbb6fc9e15dd561.zip |
Makefile.am: Enable -Wall -Werror for libpdbg
Several minor fixes were required to enable building on both x64 and ARM with
-Wall -Werror, mostly related to unused variables and bad printf string formats.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Diffstat (limited to 'libpdbg')
-rw-r--r-- | libpdbg/adu.c | 9 | ||||
-rw-r--r-- | libpdbg/bmcfsi.c | 4 | ||||
-rw-r--r-- | libpdbg/cfam.c | 7 | ||||
-rw-r--r-- | libpdbg/chip.c | 2 | ||||
-rw-r--r-- | libpdbg/device.c | 2 | ||||
-rw-r--r-- | libpdbg/i2c.c | 5 | ||||
-rw-r--r-- | libpdbg/kernel.c | 12 | ||||
-rw-r--r-- | libpdbg/p8chip.c | 15 | ||||
-rw-r--r-- | libpdbg/p9chip.c | 13 | ||||
-rw-r--r-- | libpdbg/target.c | 4 |
10 files changed, 42 insertions, 31 deletions
diff --git a/libpdbg/adu.c b/libpdbg/adu.c index f2f6649..3d6f662 100644 --- a/libpdbg/adu.c +++ b/libpdbg/adu.c @@ -16,6 +16,7 @@ #include <stdio.h> #include <stdint.h> #include <string.h> +#include <inttypes.h> #include "operations.h" #include "bitutils.h" @@ -221,7 +222,7 @@ retry: goto retry; else { PR_ERROR("Unable to read memory. " \ - "ALTD_STATUS_REG = 0x%016llx\n", val); + "ALTD_STATUS_REG = 0x%016" PRIx64 "\n", val); return -1; } } @@ -277,7 +278,7 @@ retry: goto retry; else { PR_ERROR("Unable to write memory. " \ - "P8_ALTD_STATUS_REG = 0x%016llx\n", val); + "P8_ALTD_STATUS_REG = 0x%016" PRIx64 "\n", val); rc = -1; } } @@ -323,7 +324,7 @@ retry: goto retry; else { PR_ERROR("Unable to read memory. " \ - "ALTD_STATUS_REG = 0x%016llx\n", val); + "ALTD_STATUS_REG = 0x%016" PRIx64 "\n", val); return -1; } } @@ -375,7 +376,7 @@ retry: goto retry; else { PR_ERROR("Unable to read memory. " \ - "ALTD_STATUS_REG = 0x%016llx\n", val); + "ALTD_STATUS_REG = 0x%016" PRIx64 "\n", val); return -1; } } diff --git a/libpdbg/bmcfsi.c b/libpdbg/bmcfsi.c index 0687895..12f3a5f 100644 --- a/libpdbg/bmcfsi.c +++ b/libpdbg/bmcfsi.c @@ -23,6 +23,7 @@ #include <sys/mman.h> #include <time.h> #include <assert.h> +#include <inttypes.h> #include "bitutils.h" #include "operations.h" @@ -310,7 +311,7 @@ static enum fsi_result fsi_read_resp(uint64_t *result, int len) } if (crc != 0) { - fprintf(stderr, "CRC error: 0x%llx\n", resp); + fprintf(stderr, "CRC error: 0x%" PRIx64 "\n", resp); return FSI_MERR_C; } @@ -447,7 +448,6 @@ void fsi_destroy(struct target *target) int bmcfsi_probe(struct target *target) { struct fsi *fsi = target_to_fsi(target); - uint64_t value; if (!mem_fd) { mem_fd = open("/dev/mem", O_RDWR | O_SYNC); diff --git a/libpdbg/cfam.c b/libpdbg/cfam.c index 54eb4b5..65e5d48 100644 --- a/libpdbg/cfam.c +++ b/libpdbg/cfam.c @@ -17,6 +17,7 @@ */ #include <unistd.h> #include <stdio.h> +#include <inttypes.h> #include "target.h" #include "bitutils.h" @@ -133,7 +134,7 @@ static uint64_t opb_poll(struct opb *opb, uint32_t *read_data) rc = pib_read(&opb->target, PIB2OPB_REG_STAT, &sval); if (rc) { /* Do something here ? */ - PR_ERROR("XSCOM error %lld read OPB STAT\n", rc); + PR_ERROR("XSCOM error %" PRId64 " read OPB STAT\n", rc); return -1; } PR_DEBUG(" STAT=0x%16llx...\n", sval); @@ -190,7 +191,7 @@ static int p8_opb_read(struct opb *opb, uint32_t addr, uint32_t *data) rc = pib_write(&opb->target, PIB2OPB_REG_CMD, opb_cmd); if (rc) { - PR_ERROR("XSCOM error %lld writing OPB CMD\n", rc); + PR_ERROR("XSCOM error %" PRId64 " writing OPB CMD\n", rc); return OPB_ERR_XSCOM_ERR; } return opb_poll(opb, data); @@ -213,7 +214,7 @@ static int p8_opb_write(struct opb *opb, uint32_t addr, uint32_t data) rc = pib_write(&opb->target, PIB2OPB_REG_CMD, opb_cmd); if (rc) { - PR_ERROR("XSCOM error %lld writing OPB CMD\n", rc); + PR_ERROR("XSCOM error %" PRId64 " writing OPB CMD\n", rc); return OPB_ERR_XSCOM_ERR; } return opb_poll(opb, NULL); diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 5265afe..70d349d 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -126,7 +126,7 @@ int ram_stop_thread(struct target *thread_target) static int ram_instructions(struct thread *thread, uint64_t *opcodes, uint64_t *results, int len, unsigned int lpar) { - uint64_t ram_mode, opcode, r0 = 0, r1 = 0, scratch = 0; + uint64_t opcode = 0, r0 = 0, r1 = 0, scratch = 0; int i; int exception = 0; diff --git a/libpdbg/device.c b/libpdbg/device.c index 725d656..8995f20 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -311,7 +311,7 @@ static const char *__dt_path_split(const char *p, struct dt_node *dt_find_by_path(struct dt_node *root, const char *path) { struct dt_node *n; - const char *pn, *pa, *p = path, *nn, *na; + const char *pn, *pa = NULL, *p = path, *nn = NULL, *na = NULL; unsigned int pnl, pal, nnl, nal; bool match; diff --git a/libpdbg/i2c.c b/libpdbg/i2c.c index b2a913d..3e98c1b 100644 --- a/libpdbg/i2c.c +++ b/libpdbg/i2c.c @@ -106,6 +106,10 @@ static int i2c_putscom(struct pib *pib, uint64_t addr, uint64_t value) return 0; } +#if 0 +/* TODO: At present we don't have a generic destroy method as there aren't many + * use cases for it. So for the moment we can just let the OS close the file + * descriptor on exit. */ static void i2c_destroy(struct pib *pib) { struct i2c_data *i2c_data = pib->priv; @@ -113,6 +117,7 @@ static void i2c_destroy(struct pib *pib) close(i2c_data->fd); free(i2c_data); } +#endif /* * Initialise a i2c backend on the given bus at the given bus address. diff --git a/libpdbg/kernel.c b/libpdbg/kernel.c index 7c05b90..17c7962 100644 --- a/libpdbg/kernel.c +++ b/libpdbg/kernel.c @@ -51,7 +51,7 @@ static int kernel_fsi_getcfam(struct fsi *fsi, uint32_t addr64, uint32_t *value) /* We expect reads of 0xc09 to occasionally * fail as the probing code uses it to see * if anything is present on the link. */ - warn("Failed to read from 0x%08x (%016llx)", (uint32_t)addr, addr64); + warn("Failed to read from 0x%08" PRIx32 " (%016" PRIx32 ")", (uint32_t) addr, addr64); return errno; } *value = be32toh(tmp); @@ -73,17 +73,22 @@ static int kernel_fsi_putcfam(struct fsi *fsi, uint32_t addr64, uint32_t data) tmp = htobe32(data); rc = write(fsi_fd, &tmp, 4); if (rc < 0) { - warn("Failed to write to 0x%08x (%016llx)", addr, addr64); + warn("Failed to write to 0x%08" PRIx32 " (%016" PRIx32 ")", addr, addr64); return errno; } return 0; } +#if 0 +/* TODO: At present we don't have a generic destroy method as there aren't many + * use cases for it. So for the moment we can just let the OS close the file + * descriptor on exit. */ static void kernel_fsi_destroy(struct target *target) { close(fsi_fd); } +#endif static void kernel_fsi_scan_devices(void) { @@ -103,9 +108,6 @@ static void kernel_fsi_scan_devices(void) int kernel_fsi_probe(struct target *target) { - struct fsi *fsi = target_to_fsi(target); - uint64_t value; - if (!fsi_fd) { int tries = 5; diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index c11b68c..e882749 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -19,6 +19,7 @@ #include <stdlib.h> #include <ccan/array_size/array_size.h> #include <unistd.h> +#include <inttypes.h> #include "target.h" #include "operations.h" @@ -85,7 +86,7 @@ static int assert_special_wakeup(struct chiplet *chip) CHECK_ERR(pib_read(&chip->target, EX_PM_GP0_REG, &gp0)); if (i++ > SPECIAL_WKUP_TIMEOUT) { - PR_ERROR("Timeout waiting for special wakeup on %s@0x%08lx\n", chip->target.name, + PR_ERROR("Timeout waiting for special wakeup on %s@0x%08" PRIx64 "\n", chip->target.name, dt_get_address(chip->target.dn, 0, NULL)); return -1; } @@ -94,6 +95,8 @@ static int assert_special_wakeup(struct chiplet *chip) return 0; } +#if 0 +/* TODO: Work out when to do this. */ static int deassert_special_wakeup(struct chiplet *chip) { /* Assert special wakeup to prevent low power states */ @@ -101,6 +104,7 @@ static int deassert_special_wakeup(struct chiplet *chip) return 0; } +#endif static uint64_t get_thread_status(struct thread *thread) { @@ -168,7 +172,7 @@ static int p8_thread_stop(struct thread *thread) /* Wait for thread to quiese */ CHECK_ERR(pib_read(&chip->target, RAS_STATUS_REG, &val)); if (i++ > RAS_STATUS_TIMEOUT) { - PR_ERROR("Unable to quiesce thread %d (0x%016llx).\n", + PR_ERROR("Unable to quiesce thread %d (0x%016" PRIx64 ").\n", thread->id, val); PR_ERROR("Continuing anyway.\n"); if (val & PPC_BIT(48)) { @@ -265,13 +269,15 @@ static int p8_ram_instruction(struct thread *thread, uint64_t opcode, uint64_t * if (GETFIELD(PPC_BITMASK(2,3), val) == 0x3) { return 1; } else { - PR_ERROR("RAMMING failed with status 0x%llx\n", val); + PR_ERROR("RAMMING failed with status 0x%" PRIx64 "\n", val); return 2; } } /* Save the results */ CHECK_ERR(pib_read(&chip->target, SCR0_REG, scratch)); + + return 0; } static int p8_ram_destroy(struct thread *thread) @@ -283,6 +289,8 @@ static int p8_ram_destroy(struct thread *thread) CHECK_ERR(pib_read(&chip->target, RAM_MODE_REG, &ram_mode)); ram_mode &= ~RAM_MODE_ENABLE; CHECK_ERR(pib_write(&chip->target, RAM_MODE_REG, ram_mode)); + + return 0; } /* @@ -318,7 +326,6 @@ static int p8_chiplet_probe(struct target *target) { uint64_t value; struct chiplet *chiplet = target_to_chiplet(target); - int i, count = 0, rc = 0; /* Work out if this chip is actually present */ if (pib_read(target, SCOM_EX_GP3, &value)) { diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c index ed0fdeb..677401e 100644 --- a/libpdbg/p9chip.c +++ b/libpdbg/p9chip.c @@ -18,6 +18,7 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <inttypes.h> #include "target.h" #include "operations.h" @@ -72,7 +73,6 @@ static uint64_t p9_get_thread_status(struct thread *thread) static int p9_thread_probe(struct target *target) { struct thread *thread = target_to_thread(target); - uint64_t value; thread->id = dt_prop_get_u32(target->dn, "tid"); thread->status = p9_get_thread_status(thread); @@ -82,8 +82,6 @@ static int p9_thread_probe(struct target *target) static int p9_thread_start(struct thread *thread) { - uint64_t value; - thread_write(thread, P9_DIRECT_CONTROL, PPC_BIT(6 + 8*thread->id)); thread_write(thread, P9_RAS_MODEREG, 0); @@ -93,7 +91,6 @@ static int p9_thread_start(struct thread *thread) static int p9_thread_stop(struct thread *thread) { int i = 0; - uint64_t value; thread_write(thread, P9_DIRECT_CONTROL, PPC_BIT(7 + 8*thread->id)); while(!(p9_get_thread_status(thread) & THREAD_STATUS_QUIESCE)) { @@ -114,7 +111,6 @@ static int p9_ram_setup(struct thread *thread) { struct dt_node *dn; struct chiplet *chip = target_to_chiplet(thread->target.dn->parent->target); - uint64_t ras_status; /* We can only ram a thread if all the threads on the core/chip are * quiesced */ @@ -141,7 +137,6 @@ static int p9_ram_setup(struct thread *thread) static int p9_ram_instruction(struct thread *thread, uint64_t opcode, uint64_t *scratch) { - struct chiplet *chip = target_to_chiplet(thread->target.dn->parent->target); uint64_t predecode, value; switch(opcode & OPCODE_MASK) { @@ -205,7 +200,7 @@ DECLARE_HW_UNIT(p9_thread); static int p9_chiplet_probe(struct target *target) { - int i; + int i = 0; uint64_t value; if (pib_read(target, NET_CTRL0, &value)) @@ -220,9 +215,9 @@ static int p9_chiplet_probe(struct target *target) CHECK_ERR(pib_read(target, PPM_GPMMR, &value)); if (i++ > SPECIAL_WKUP_TIMEOUT) { - PR_ERROR("Timeout waiting for special wakeup on %s@0x%08lx\n", target->name, + PR_ERROR("Timeout waiting for special wakeup on %s@0x%08" PRIx64 "\n", target->name, dt_get_address(target->dn, 0, NULL)); - return -1; + break; } } while (!(value & SPECIAL_WKUP_DONE)); diff --git a/libpdbg/target.c b/libpdbg/target.c index 7642e18..5eafde1 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -168,9 +168,9 @@ extern struct hw_init_info *__stop_hw_units; struct hw_unit_info *find_compatible_target(const char *compat) { struct hw_unit_info **p; - struct target *target, *tmp; + struct target *target; - for (p = &__start_hw_units; p < &__stop_hw_units; p++) { + for (p = &__start_hw_units; p < (struct hw_unit_info **) &__stop_hw_units; p++) { target = (*p)->hw_unit + (*p)->struct_target_offset; if (!strcmp(target->compatible, compat)) return *p; |