-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ssize_t and off_t definitions from sys/types.h #37712
Use ssize_t and off_t definitions from sys/types.h #37712
Conversation
(ent.type == FS_DIR_ENTRY_FILE) ? 'F' : 'D', | ||
ent.size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"%zu" instead
printk("FAIL: mount id %llu at %s: %d\n", | ||
(unsigned long long)mp->storage_dev, mp->mnt_point, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printk("FAIL: mount id %llu at %s: %d\n", | |
(unsigned long long)mp->storage_dev, mp->mnt_point, | |
printk("FAIL: mount id %p at %s: %d\n", | |
mp->storage_dev, mp->mnt_point, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everywhere else yes, but here no: the storage_dev for LittleFS, unfortunately, carries identifier of storage partition which is actually unsigned int:
zephyr/subsys/fs/littlefs_fs.c
Line 566 in 30b4c29
unsigned int area_id = (uintptr_t)mountp->storage_dev; |
zephyr/subsys/fs/littlefs_fs.c
Line 804 in 30b4c29
.storage_dev = (void *)DT_FIXED_PARTITION_ID(FS_PARTITION(inst)), \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case:
printk("FAIL: mount id %llu at %s: %d\n", | |
(unsigned long long)mp->storage_dev, mp->mnt_point, | |
printk("FAIL: mount id %" PRIuPTR " at %s: %d\n", | |
(uintptr_t)mp->storage_dev, mp->mnt_point, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree; C pointers should only be converted to integer types via[u]intptr_t
casts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephanosio Argh. The clang does not want to play nice with this. Will go back to (unsigned long long) as safe option and will mark this as TODO to fix when the clang gets older.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error: format specifies type 'unsigned int' but the argument has type 'uintptr_t' (aka 'unsigned long') [-Werror,-Wformat]
Hold on, something is not right there ... we should not be seeing that warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This goes back to #16645, where we defined __INTPTR_TYPE__
and __UINTPTR_TYPE__
as long int
and long unsigned int
, respectively. These are used by the GCC and Clang headers to typedef intptr_t
and uintptr_t
.
zephyr/include/toolchain/zephyr_stdint.h
Lines 47 to 50 in feb0e9f
#undef __INTPTR_TYPE__ | |
#undef __UINTPTR_TYPE__ | |
#define __INTPTR_TYPE__ long int | |
#define __UINTPTR_TYPE__ long unsigned int |
By default, x86-32 Clang defines __INTPTR_TYPE__
as int
, but we override that to long int
in zephyr_stdint.h
, so our intptr_t
becomes long int
(aka. long
), and the Clang inttypes.h
for x86-32 still defines PRIuPTR
as %u
and not %lu
, so we get this warning/error.
This is yet another type system-related bug and needs to be fixed. I will create an issue for this.
Meanwhile, please feel free to go with your previous implementation for now (would be nice to add a FIXME
comment though).
e73702c
to
7693ab8
Compare
013c26f
to
eb0871e
Compare
The sys/types.h definitions of ssize_t and off_t will be used. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
eb0871e
to
d2a900d
Compare
The formatting options, passed to the printk, caused warnings when compiling for native_posix_64. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
d2a900d
to
798ea6b
Compare
The PR contains two commits:
Fixes: #37665