mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-02-06 02:03:05 +08:00
jffs2: Resolve signed comparison warnings
JFFS2 uses the high values of the unsigned flash offset in a raw node reference as special identifiers and specifies them using negative integer literals. This disables those errors for non-RTEMS source and constrains such comparisons in RTEMS code to avoid larger reworks of the JFFS2 upstream source.
This commit is contained in:
committed by
Joel Sherrill
parent
578d2e4e46
commit
76614d5200
@@ -98,6 +98,25 @@ struct jffs2_raw_node_ref
|
||||
/* Use blocks of about 256 bytes */
|
||||
#define REFS_PER_BLOCK ((255/sizeof(struct jffs2_raw_node_ref))-1)
|
||||
|
||||
#ifdef __rtems__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
/*
|
||||
* The REF_LINK_NODE and REF_EMPTY_NODE macros should really be uint32_t bit
|
||||
* patterns instead of signed integer literals to avoid signed comparison
|
||||
* warnings. This contains all comparisons using them to this section where
|
||||
* signed comparison warnings are disabled.
|
||||
*/
|
||||
static inline bool rtems_jffs2_is_ref_link(struct jffs2_raw_node_ref *ref)
|
||||
{
|
||||
return ref->flash_offset == REF_LINK_NODE;
|
||||
}
|
||||
|
||||
static inline bool rtems_jffs2_is_ref_empty(struct jffs2_raw_node_ref *ref)
|
||||
{
|
||||
return ref->flash_offset == REF_EMPTY_NODE;
|
||||
}
|
||||
#endif
|
||||
static inline struct jffs2_raw_node_ref *ref_next(struct jffs2_raw_node_ref *ref)
|
||||
{
|
||||
ref++;
|
||||
@@ -115,6 +134,9 @@ static inline struct jffs2_raw_node_ref *ref_next(struct jffs2_raw_node_ref *ref
|
||||
|
||||
return ref;
|
||||
}
|
||||
#ifdef __rtems__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ static struct jffs2_raw_node_ref *jffs2_alloc_refblock(void)
|
||||
|
||||
ret = malloc((REFS_PER_BLOCK + 1) * sizeof(*ret));
|
||||
if (ret) {
|
||||
int i = 0;
|
||||
uint32_t i = 0;
|
||||
for (i=0; i < REFS_PER_BLOCK; i++) {
|
||||
ret[i].flash_offset = REF_EMPTY_NODE;
|
||||
ret[i].next_in_ino = NULL;
|
||||
@@ -95,7 +95,7 @@ int jffs2_prealloc_raw_node_refs(struct jffs2_sb_info *c,
|
||||
ref = *p;
|
||||
|
||||
/* If jeb->last_node is really a valid node then skip over it */
|
||||
if (ref && ref->flash_offset != REF_EMPTY_NODE)
|
||||
if (ref && !rtems_jffs2_is_ref_empty(ref))
|
||||
ref++;
|
||||
|
||||
while (i) {
|
||||
@@ -104,7 +104,7 @@ int jffs2_prealloc_raw_node_refs(struct jffs2_sb_info *c,
|
||||
if (!ref)
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (ref->flash_offset == REF_LINK_NODE) {
|
||||
if (rtems_jffs2_is_ref_link(ref)) {
|
||||
p = &ref->next_in_ino;
|
||||
ref = *p;
|
||||
continue;
|
||||
|
||||
@@ -3,6 +3,7 @@ build-type: objects
|
||||
cflags:
|
||||
- ${COVERAGE_COMPILER_FLAGS}
|
||||
- -Wno-pointer-sign
|
||||
- -Wno-sign-compare
|
||||
copyrights:
|
||||
- Copyright (C) 2020 embedded brains GmbH & Co. KG
|
||||
cppflags: []
|
||||
|
||||
Reference in New Issue
Block a user