Message ID | 20220210185234.41362-1-cgzones@googlemail.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [1/3] libsepol: use correct error type to please UBSAN | expand |
On Thu, Feb 10, 2022 at 4:09 PM Christian Göttsche <cgzones@googlemail.com> wrote: > > The callback function apply in hashtap_map has a return type of int and > can return -1 on error. Use int as type to save the return value to > avoid implicit conversions: > > hashtab.c:236:10: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned int' changed the value to 4294967295 (32-bit, unsigned) > > Signed-off-by: Christian Göttsche <cgzones@googlemail.com> For all three patches: Acked-by: James Carter <jwcart2@gmail.com> > --- > libsepol/src/hashtab.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libsepol/src/hashtab.c b/libsepol/src/hashtab.c > index 2eb35212..3ecaf165 100644 > --- a/libsepol/src/hashtab.c > +++ b/libsepol/src/hashtab.c > @@ -224,8 +224,9 @@ int hashtab_map(hashtab_t h, > int (*apply) (hashtab_key_t k, > hashtab_datum_t d, void *args), void *args) > { > - unsigned int i, ret; > + unsigned int i; > hashtab_ptr_t cur; > + int ret; > > if (!h) > return SEPOL_OK; > -- > 2.34.1 >
On Mon, Feb 14, 2022 at 2:59 PM James Carter <jwcart2@gmail.com> wrote: > > On Thu, Feb 10, 2022 at 4:09 PM Christian Göttsche > <cgzones@googlemail.com> wrote: > > > > The callback function apply in hashtap_map has a return type of int and > > can return -1 on error. Use int as type to save the return value to > > avoid implicit conversions: > > > > hashtab.c:236:10: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned int' changed the value to 4294967295 (32-bit, unsigned) > > > > Signed-off-by: Christian Göttsche <cgzones@googlemail.com> > > For all three patches: > Acked-by: James Carter <jwcart2@gmail.com> > These three patches have been merged. Thanks, Jim > > --- > > libsepol/src/hashtab.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/libsepol/src/hashtab.c b/libsepol/src/hashtab.c > > index 2eb35212..3ecaf165 100644 > > --- a/libsepol/src/hashtab.c > > +++ b/libsepol/src/hashtab.c > > @@ -224,8 +224,9 @@ int hashtab_map(hashtab_t h, > > int (*apply) (hashtab_key_t k, > > hashtab_datum_t d, void *args), void *args) > > { > > - unsigned int i, ret; > > + unsigned int i; > > hashtab_ptr_t cur; > > + int ret; > > > > if (!h) > > return SEPOL_OK; > > -- > > 2.34.1 > >
diff --git a/libsepol/src/hashtab.c b/libsepol/src/hashtab.c index 2eb35212..3ecaf165 100644 --- a/libsepol/src/hashtab.c +++ b/libsepol/src/hashtab.c @@ -224,8 +224,9 @@ int hashtab_map(hashtab_t h, int (*apply) (hashtab_key_t k, hashtab_datum_t d, void *args), void *args) { - unsigned int i, ret; + unsigned int i; hashtab_ptr_t cur; + int ret; if (!h) return SEPOL_OK;
The callback function apply in hashtap_map has a return type of int and can return -1 on error. Use int as type to save the return value to avoid implicit conversions: hashtab.c:236:10: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned int' changed the value to 4294967295 (32-bit, unsigned) Signed-off-by: Christian Göttsche <cgzones@googlemail.com> --- libsepol/src/hashtab.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)