This is a stack of patches that piled up while working on the harmonization of the common codebase of barebox and dt-utils. Although I already addressed many warnings there is still work to do as you can see when building with "-Wall". Ulrich Ölmann (12): common: align declarations of dev_add_param_*() functions with barebox of_get_devicepath: again correct comment barebox-state: fix usage of multiple state instances barebox-state: complete cmdline options barebox-state: add cmdline option "--version" barebox-state: remove declaration of __state_uint8_get() barebox-state: remove unused variables keystore-blob: remove unused variable base64: remove unused variable base64: remove duplicate ‘const’ declaration specifier state: fix formatting of "off_t" variables state: fix formatting of "uint32_t" variables src/barebox-state.c | 20 +++++++----- src/barebox-state/backend_bucket_circular.c | 34 ++++++++++----------- src/barebox-state/backend_storage.c | 20 ++++++------ src/base64.c | 17 ++--------- src/dt/common.h | 8 ++--- src/keystore-blob.c | 2 +- src/libdt.c | 7 +++-- 7 files changed, 51 insertions(+), 57 deletions(-) -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
The only remaining difference is the argument "value" in dev_add_param_enum() which is of type int* in barebox and got type uint32_t* here to not let the compiler warn about assignment of pointers of different signedness. There is no such warning when compiling barebox as it's applying the compiler option "-Wno-pointer-sign" in its main makefile. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/dt/common.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dt/common.h b/src/dt/common.h index de8d2938a149..c3c4f53fc216 100644 --- a/src/dt/common.h +++ b/src/dt/common.h @@ -368,7 +368,7 @@ struct device_d { static inline struct param_d *dev_add_param_enum(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - int *value, const char **names, int max, void *priv) + uint32_t *value, const char * const *names, int max, void *priv) { return NULL; @@ -377,7 +377,7 @@ static inline struct param_d *dev_add_param_enum(struct device_d *dev, const cha static inline struct param_d *dev_add_param_bool(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - int *value, void *priv) + uint32_t *value, void *priv) { return NULL; } @@ -385,7 +385,7 @@ static inline struct param_d *dev_add_param_bool(struct device_d *dev, const cha static inline struct param_d *dev_add_param_mac(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - uint8_t *mac, void *priv) + u8 *mac, void *priv) { return NULL; } @@ -401,7 +401,7 @@ static inline struct param_d *dev_add_param_string(struct device_d *dev, const c static inline struct param_d *dev_add_param_uint32(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - int *value, const char *format, void *priv) + uint32_t *value, const char *format, void *priv) { return NULL; } -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
The cited patch went mainline meanwhile so reflect that in the comment. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/libdt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libdt.c b/src/libdt.c index 4638678fcd30..8ae9978c66c2 100644 --- a/src/libdt.c +++ b/src/libdt.c @@ -2391,9 +2391,10 @@ int of_get_devicepath(struct device_node *partition_node, char **devpath, off_t /* * simplest case: This nodepath can directly be translated into - * an eeprom, mtd or block device. Note that for the mtd case an - * out-of-tree kernel patch is required - * (https://patchwork.ozlabs.org/patch/726037/). + * an eeprom, mtd or block device. Note that for the mtd case a + * kernel >= v4.11 is required as it includes the needed commit + * 42e9401bd146 ("mtd: Add partition device node to mtd partition + * devices"). */ dev = of_find_device_by_node_path(partition_node->full_name); if (dev) { -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
Let's assume there are two state instances named "blue" (with variable "x") and "yellow" (with variable "y") then $ barebox-state --name blue --get x $ barebox-state --name yellow --get y would both work, whereas only exactly one of the alternative calls $ barebox-state --get blue.x $ barebox-state --get yellow.y would succeed. This commit fixes that bug. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/barebox-state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/barebox-state.c b/src/barebox-state.c index 3e6c26003462..76d047559a4f 100644 --- a/src/barebox-state.c +++ b/src/barebox-state.c @@ -581,9 +581,10 @@ int main(int argc, char *argv[]) list_for_each_entry(state, &state_list.list, list) { if (strlen(state->name) == statename_len && - !strncmp(state->name, sg->arg, statename_len)) + !strncmp(state->name, sg->arg, statename_len)) { arg = statename_end + 1; break; + } } } if (state == &state_list) { -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
Make the commandline options consistent and complete: - option "-h" already had a long equivalent "--help", so reflect that in the usage() message. - for option "-q" the usage() message promised a long equivalent "--quiet" that did not exist. - the call to getopt_long() already allowed the option "-f" in its optstring, but the usage() message said nothing about it, hence amend that and offer the long option "--force" as well. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/barebox-state.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/barebox-state.c b/src/barebox-state.c index 76d047559a4f..0f40044bc2c6 100644 --- a/src/barebox-state.c +++ b/src/barebox-state.c @@ -374,7 +374,9 @@ static struct option long_options[] = { {"name", required_argument, 0, 'n' }, {"dump", no_argument, 0, 'd' }, {"dump-shell", no_argument, 0, OPT_DUMP_SHELL }, + {"force", no_argument, 0, 'f' }, {"verbose", no_argument, 0, 'v' }, + {"quiet", no_argument, 0, 'q' }, {"help", no_argument, 0, 'h' }, { } }; @@ -389,9 +391,10 @@ static void usage(char *name) "-n, --name <name> specify the state to use (default=\"state\"). Multiple states are allowed.\n" "-d, --dump dump the state\n" "--dump-shell dump the state suitable for shell sourcing\n" +"-f, --force do not check for state manipulation via the HMAC\n" "-v, --verbose increase verbosity\n" "-q, --quiet decrease verbosity\n" -"--help this help\n", +"-h, --help this help\n", name); } -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/barebox-state.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/barebox-state.c b/src/barebox-state.c index 0f40044bc2c6..4e087b9d63bf 100644 --- a/src/barebox-state.c +++ b/src/barebox-state.c @@ -366,6 +366,7 @@ struct state *state_get(const char *name, bool readonly, bool auth) enum opt { OPT_DUMP_SHELL = UCHAR_MAX + 1, + OPT_VERSION = UCHAR_MAX + 2, }; static struct option long_options[] = { @@ -377,6 +378,7 @@ static struct option long_options[] = { {"force", no_argument, 0, 'f' }, {"verbose", no_argument, 0, 'v' }, {"quiet", no_argument, 0, 'q' }, + {"version", no_argument, 0, OPT_VERSION }, {"help", no_argument, 0, 'h' }, { } }; @@ -394,6 +396,7 @@ static void usage(char *name) "-f, --force do not check for state manipulation via the HMAC\n" "-v, --verbose increase verbosity\n" "-q, --quiet decrease verbosity\n" +"--version display version\n" "-h, --help this help\n", name); } @@ -439,6 +442,9 @@ int main(int argc, char *argv[]) case 'h': usage(argv[0]); exit(0); + case OPT_VERSION: + printf(PACKAGE_STRING "\n"); + exit(0); case 'g': sg = xzalloc(sizeof(*sg)); sg->get = 1; -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
By cleaning up the code the compiler does not emit the following warning anymore: src/barebox-state.c:44:14: warning: ‘__state_uint8_get’ declared ‘static’ but never defined [-Wunused-function] static char *__state_uint8_get(struct state_variable *var); ^~~~~~~~~~~~~~~~~ The function is not needed as its job is done by __state_uint32_get(). Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/barebox-state.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/barebox-state.c b/src/barebox-state.c index 4e087b9d63bf..fc9a7bb055ef 100644 --- a/src/barebox-state.c +++ b/src/barebox-state.c @@ -41,7 +41,6 @@ struct state_variable; static int __state_uint8_set(struct state_variable *var, const char *val); -static char *__state_uint8_get(struct state_variable *var); static int __state_uint32_set(struct state_variable *var, const char *val); static char *__state_uint32_get(struct state_variable *var); static int __state_enum32_set(struct state_variable *sv, const char *val); -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
By cleaning up the code the compiler does not emit the following warning anymore: src/barebox-state.c: In function '__state_string_get': src/barebox-state.c:254:6: warning: unused variable 'ret' [-Wunused-variable] int ret; ^~~ src/barebox-state.c: In function 'state_get': src/barebox-state.c:317:25: warning: unused variable 'v' [-Wunused-variable] struct state_variable *v; ^ src/barebox-state.c:316:14: warning: unused variable 'backend_type' [-Wunused-variable] const char *backend_type = NULL; ^~~~~~~~~~~~ src/barebox-state.c:313:8: warning: unused variable 'path' [-Wunused-variable] char *path; ^~~~ src/barebox-state.c: In function 'main': src/barebox-state.c:561:9: warning: unused variable 'i' [-Wunused-variable] int i; ^ Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/barebox-state.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/barebox-state.c b/src/barebox-state.c index fc9a7bb055ef..946a8dba6d8c 100644 --- a/src/barebox-state.c +++ b/src/barebox-state.c @@ -251,7 +251,6 @@ static char *__state_string_get(struct state_variable *var) { struct state_string *string = to_state_string(var); char *str; - int ret; if (string->raw[0]) str = strndup(string->raw, string->var.size); @@ -310,11 +309,8 @@ static int state_set_var(struct state *state, const char *var, const char *val) struct state *state_get(const char *name, bool readonly, bool auth) { struct device_node *root, *node; - char *path; struct state *state; int ret; - const char *backend_type = NULL; - struct state_variable *v; root = of_read_proc_devicetree(); if (IS_ERR(root)) { @@ -564,7 +560,6 @@ int main(int argc, char *argv[]) state_for_each_var(state->state, v) { struct variable_str_type *vtype; char *name, *ptr; - int i; /* replace "." by "_" to make it var name shell compatible */ name = strdup(v->name); -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
By cleaning up the code the compiler does not emit the following warning anymore: src/keystore-blob.c: In function 'keystore_get_secret': src/keystore-blob.c:25:15: warning: unused variable 'modifier' [-Wunused-variable] char *blob, *modifier, *payload; ^~~~~~~~ Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/keystore-blob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/keystore-blob.c b/src/keystore-blob.c index 028dd8bcc9be..f71ff5d9d5cb 100644 --- a/src/keystore-blob.c +++ b/src/keystore-blob.c @@ -22,7 +22,7 @@ static struct state *state; int keystore_get_secret(const char *name, const unsigned char **key, int *key_len) { FILE *fp; - char *blob, *modifier, *payload; + char *blob, *payload; u8 *blob_bin, *payload_bin; ssize_t len; int fd, ret; -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
The variable seems to be a leftover from importing the function from busybox-1.23.2 and by cleaning up the code the compiler does not emit the following warning anymore: src/base64.c:34:14: warning: variable ‘src_tail’ set but not used [-Wunused-but-set-variable] const char *src_tail; ^~~~~~~~ Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/base64.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/base64.c b/src/base64.c index 02cac16a4a58..270c64add259 100644 --- a/src/base64.c +++ b/src/base64.c @@ -31,7 +31,6 @@ static const char const uuenc_tbl_base64[65 + 1] = { */ int decode_base64(char *p_dst, int dst_len, const char *src) { - const char *src_tail; char *dst = p_dst; int length = 0; @@ -40,7 +39,6 @@ int decode_base64(char *p_dst, int dst_len, const char *src) int count = 0; /* Fetch up to four 6-bit values */ - src_tail = src; while (count < 4) { const char *table_ptr; int ch; @@ -54,18 +52,9 @@ int decode_base64(char *p_dst, int dst_len, const char *src) */ do { ch = *src; - if (ch == '\0') { - /* - * Example: - * If we decode "QUJD <NUL>", we want - * to return ptr to NUL, not to ' ', - * because we did fully decode - * the string (to "ABC"). - */ - if (count == 0) - src_tail = src; + if (ch == '\0') goto ret; - } + src++; table_ptr = strchr(uuenc_tbl_base64, ch); } while (!table_ptr); -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
By cleaning up the code the compiler does not emit the following warning anymore: src/base64.c:15:19: warning: duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier] static const char const uuenc_tbl_base64[65 + 1] = { ^~~~~ Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/base64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base64.c b/src/base64.c index 270c64add259..6c02174d6377 100644 --- a/src/base64.c +++ b/src/base64.c @@ -12,7 +12,7 @@ #include <base64.h> /* Conversion table. for base 64 */ -static const char const uuenc_tbl_base64[65 + 1] = { +static const char uuenc_tbl_base64[65 + 1] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
Explicitely casting an "off_t" variable to "long long" and formatting it via "%lld" or "%llx" respectively makes 32- as well as 64-bit compilers happy (tested with gcc-8.2.1 and clang-7.0.1). Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/barebox-state/backend_bucket_circular.c | 32 ++++++++++----------- src/barebox-state/backend_storage.c | 20 ++++++------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c index fc6911ac717c..e96849df9220 100644 --- a/src/barebox-state/backend_bucket_circular.c +++ b/src/barebox-state/backend_bucket_circular.c @@ -165,11 +165,11 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ ret = lseek(circ->fd, offset, SEEK_SET); if (ret < 0) { dev_err(circ->dev, "Failed to set circular read position to %lld, %d\n", - offset, ret); + (long long) offset, ret); return ret; } - dev_dbg(circ->dev, "Read state from %ld length %d\n", offset, + dev_dbg(circ->dev, "Read state from %lld length %d\n", (long long) offset, len); @@ -194,15 +194,15 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir ret = lseek(circ->fd, offset, SEEK_SET); if (ret < 0) { - dev_err(circ->dev, "Failed to set position for circular write %ld, %d\n", - offset, ret); + dev_err(circ->dev, "Failed to set position for circular write %lld, %d\n", + (long long) offset, ret); return ret; } ret = write_full(circ->fd, buf, len); if (ret < 0) { - dev_err(circ->dev, "Failed to write circular to %ld length %d, %d\n", - offset, len, ret); + dev_err(circ->dev, "Failed to write circular to %lld length %d, %d\n", + (long long) offset, len, ret); return ret; } @@ -212,8 +212,8 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir */ flush(circ->fd); - dev_dbg(circ->dev, "Written state to offset %ld length %d data length %d\n", - offset, len, len); + dev_dbg(circ->dev, "Written state to offset %lld length %d data length %d\n", + (long long) offset, len, len); return 0; } @@ -270,8 +270,8 @@ static int state_backend_bucket_circular_read(struct state_backend_storage_bucke if (!buf) return -ENOMEM; - dev_dbg(circ->dev, "Read state from PEB %u global offset %ld length %zd\n", - circ->eraseblock, offset, read_len); + dev_dbg(circ->dev, "Read state from PEB %u global offset %lld length %zd\n", + circ->eraseblock, (long long) offset, read_len); ret = state_mtd_peb_read(circ, buf, offset, read_len); if (ret < 0 && ret != -EUCLEAN) { @@ -350,13 +350,13 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck ret = state_mtd_peb_write(circ, write_buf, offset, written_length); if (ret < 0 && ret != -EUCLEAN) { - dev_err(circ->dev, "Failed to write circular to %ld length %d, %d\n", - offset, written_length, ret); + dev_err(circ->dev, "Failed to write circular to %lld length %d, %d\n", + (long long) offset, written_length, ret); goto out_free; } - dev_dbg(circ->dev, "Written state to PEB %u offset %ld length %d data length %zd\n", - circ->eraseblock, offset, written_length, len); + dev_dbg(circ->dev, "Written state to PEB %u offset %lld length %d data length %zd\n", + circ->eraseblock, (long long) offset, written_length, len); out_free: free(write_buf); @@ -450,8 +450,8 @@ static int bucket_circular_is_block_bad(struct state_backend_storage_bucket_circ ret = ioctl(circ->fd, MEMGETBADBLOCK, &offs); if (ret < 0) - dev_err(circ->dev, "Failed to use ioctl to check for bad block at offset %ld, %d\n", - offs, ret); + dev_err(circ->dev, "Failed to use ioctl to check for bad block at offset %lld, %d\n", + (long long) offs, ret); return ret; } diff --git a/src/barebox-state/backend_storage.c b/src/barebox-state/backend_storage.c index f8c432b6a1be..3879a8d35666 100644 --- a/src/barebox-state/backend_storage.c +++ b/src/barebox-state/backend_storage.c @@ -111,11 +111,11 @@ refresh: ret = bucket->write(bucket, buf, len); if (ret) { - dev_warn(storage->dev, "Failed to restore bucket %d@0x%08lx\n", - bucket->num, bucket->offset); + dev_warn(storage->dev, "Failed to restore bucket %d@0x%08llx\n", + bucket->num, (long long) bucket->offset); } else { - dev_info(storage->dev, "restored bucket %d@0x%08lx\n", - bucket->num, bucket->offset); + dev_info(storage->dev, "restored bucket %d@0x%08llx\n", + bucket->num, (long long) bucket->offset); bucket->needs_refresh = 0; } @@ -166,7 +166,7 @@ int state_storage_read(struct state_backend_storage *storage, if (!ret && !bucket_used) bucket_used = bucket; if (ret) - dev_info(storage->dev, "Ignoring broken bucket %d@0x%08lx...\n", bucket->num, bucket->offset); + dev_info(storage->dev, "Ignoring broken bucket %d@0x%08llx...\n", bucket->num, (long long) bucket->offset); } dev_dbg(storage->dev, "Checking redundant buckets finished.\n"); @@ -177,7 +177,7 @@ int state_storage_read(struct state_backend_storage *storage, return -ENOENT; } - dev_info(storage->dev, "Using bucket %d@0x%08lx\n", bucket_used->num, bucket_used->offset); + dev_info(storage->dev, "Using bucket %d@0x%08llx\n", bucket_used->num, (long long) bucket_used->offset); /* * Restore/refresh all buckets except the one we currently use (in case @@ -252,8 +252,8 @@ static int state_storage_mtd_buckets_init(struct state_backend_storage *storage, end = meminfo->size; if (!IS_ALIGNED(storage->offset, meminfo->erasesize)) { - dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %u\n", - storage->offset, meminfo->erasesize); + dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %lld, erasesize %u\n", + (long long) storage->offset, meminfo->erasesize); return -EINVAL; } @@ -326,8 +326,8 @@ static int state_storage_file_buckets_init(struct state_backend_storage *storage &bucket, offset, stridesize); if (ret) { - dev_warn(storage->dev, "Failed to create direct bucket at '%s' offset %ld\n", - storage->path, offset); + dev_warn(storage->dev, "Failed to create direct bucket at '%s' offset %lld\n", + storage->path, (long long) offset); continue; } -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
The format specifier "%zd" is for "size_t" typed variables and produces a warning with gcc, so use "%u" instead. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> --- src/barebox-state/backend_bucket_circular.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c index e96849df9220..aec17b312cab 100644 --- a/src/barebox-state/backend_bucket_circular.c +++ b/src/barebox-state/backend_bucket_circular.c @@ -303,7 +303,7 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck void *write_buf; if (written_length > circ->max_size) { - dev_err(circ->dev, "Error, state data too big to be written, to write: %d, writesize: %zd, length: %zd, available: %zd\n", + dev_err(circ->dev, "Error, state data too big to be written, to write: %u, writesize: %zd, length: %zd, available: %zd\n", written_length, circ->writesize, len, circ->max_size); return -E2BIG; } @@ -350,12 +350,12 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck ret = state_mtd_peb_write(circ, write_buf, offset, written_length); if (ret < 0 && ret != -EUCLEAN) { - dev_err(circ->dev, "Failed to write circular to %lld length %d, %d\n", + dev_err(circ->dev, "Failed to write circular to %lld length %u, %d\n", (long long) offset, written_length, ret); goto out_free; } - dev_dbg(circ->dev, "Written state to PEB %u offset %lld length %d data length %zd\n", + dev_dbg(circ->dev, "Written state to PEB %u offset %lld length %u data length %zd\n", circ->eraseblock, (long long) offset, written_length, len); out_free: -- 2.20.1 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
On Sunday 03 February 2019 22:48:06 Ulrich Ölmann wrote:
> Explicitely casting an "off_t" variable to "long long" and formatting it
> via "%lld" or "%llx" respectively makes 32- as well as 64-bit compilers
> happy (tested with gcc-8.2.1 and clang-7.0.1).
Könnte hier der Cast (intmax_t) und der Prefix 'j' vielleicht besser sein?
off_t blub;
printf("Blub is: %jd\n", (intmax_t)blub);
jb
_______________________________________________
OSS-Tools mailing list
OSS-Tools@pengutronix.de
On Mon, Feb 04, 2019 at 08:54:29AM +0100, Juergen Borleis wrote: > On Sunday 03 February 2019 22:48:06 Ulrich Ölmann wrote: > > Explicitely casting an "off_t" variable to "long long" and formatting it > > via "%lld" or "%llx" respectively makes 32- as well as 64-bit compilers > > happy (tested with gcc-8.2.1 and clang-7.0.1). > > Könnte hier der Cast (intmax_t) und der Prefix 'j' vielleicht besser sein? > > off_t blub; > > printf("Blub is: %jd\n", (intmax_t)blub); Note: the j length modifier exists only since glibc 2.1. Don't know about non-Linux (or alternative Linux) libc implementations. (Do we care about those?). Just checked the OpenSolaris state, printf there knows about 'j', but notes: If the j length modifier is used, 32-bit applications that were compiled using c89 on releases prior to Solaris 10 will experience undefined behavior Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
On Mon, Feb 04 2019 at 10:06 +0100, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > On Mon, Feb 04, 2019 at 08:54:29AM +0100, Juergen Borleis wrote: >> On Sunday 03 February 2019 22:48:06 Ulrich Ölmann wrote: >> > Explicitely casting an "off_t" variable to "long long" and formatting it >> > via "%lld" or "%llx" respectively makes 32- as well as 64-bit compilers >> > happy (tested with gcc-8.2.1 and clang-7.0.1). >> >> Könnte hier der Cast (intmax_t) und der Prefix 'j' vielleicht besser sein? >> >> off_t blub; >> >> printf("Blub is: %jd\n", (intmax_t)blub); > > Note: the j length modifier exists only since glibc 2.1. Don't know > about non-Linux (or alternative Linux) libc implementations. (Do we care > about those?). Just checked the OpenSolaris state, printf there knows > about 'j', but notes: > > If the j length modifier is used, 32-bit applications that > were compiled using c89 on releases prior to Solaris 10 will > experience undefined behavior Unfortunately using "%j" is not an option as this code is shared with barebox' state implementation and barebox only supports a subset of the formats that glibc offers which does not include "%j", see [1]. Best regards Ulrich [1] https://github.com/saschahauer/barebox/blob/master/lib/vsprintf.c#L364 -- Pengutronix e.K. | Ulrich Ölmann | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de
On Sun, Feb 03, 2019 at 10:47:55PM +0100, Ulrich Ölmann wrote: > This is a stack of patches that piled up while working on the harmonization of > the common codebase of barebox and dt-utils. > Although I already addressed many warnings there is still work to do as you can > see when building with "-Wall". > > Ulrich Ölmann (12): > common: align declarations of dev_add_param_*() functions with barebox > of_get_devicepath: again correct comment > barebox-state: fix usage of multiple state instances > barebox-state: complete cmdline options > barebox-state: add cmdline option "--version" > barebox-state: remove declaration of __state_uint8_get() > barebox-state: remove unused variables > keystore-blob: remove unused variable > base64: remove unused variable > base64: remove duplicate ‘const’ declaration specifier > state: fix formatting of "off_t" variables > state: fix formatting of "uint32_t" variables > > src/barebox-state.c | 20 +++++++----- > src/barebox-state/backend_bucket_circular.c | 34 ++++++++++----------- > src/barebox-state/backend_storage.c | 20 ++++++------ > src/base64.c | 17 ++--------- > src/dt/common.h | 8 ++--- > src/keystore-blob.c | 2 +- > src/libdt.c | 7 +++-- > 7 files changed, 51 insertions(+), 57 deletions(-) Applied all to next, thanks a lot! - Roland -- Roland Hieber | r.hieber@pengutronix.de | Pengutronix e.K. | https://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de