Message ID | 20200901153321.920490-1-laurent@vivier.eu |
---|---|
State | New |
Headers | show |
Series | linux-user: fix implicit conversion from enumeration type error | expand |
Patchew URL: https://patchew.org/QEMU/20200901153321.920490-1-laurent@vivier.eu/ Hi, This series seems to have some coding style problems. See output below for more information: Type: series Message-id: 20200901153321.920490-1-laurent@vivier.eu Subject: [PATCH] linux-user: fix implicit conversion from enumeration type error === TEST SCRIPT BEGIN === #!/bin/bash git rev-parse base > /dev/null || exit 0 git config --local diff.renamelimit 0 git config --local diff.renames True git config --local diff.algorithm histogram ./scripts/checkpatch.pl --mailback base.. === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test' 30ae5fc linux-user: fix implicit conversion from enumeration type error === OUTPUT BEGIN === ERROR: Macros with complex values should be enclosed in parenthesis #26: FILE: include/exec/user/thunk.h:45: +#define MK_ARRAY(type, size) TYPE_ARRAY, (int)size, type total: 1 errors, 0 warnings, 8 lines checked Commit 30ae5fc07c8d (linux-user: fix implicit conversion from enumeration type error) has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. === OUTPUT END === Test command exited with code: 1 The full log is available at http://patchew.org/logs/20200901153321.920490-1-laurent@vivier.eu/testing.checkpatch/?type=message. --- Email generated automatically by Patchew [https://patchew.org/]. Please send your feedback to patchew-devel@redhat.com
On 9/1/20 5:33 PM, Laurent Vivier wrote: > MK_ARRAY(type,size) is used to fill the field_types buffer, and if the > "size" parameter is an enum type, clang [-Werror,-Wenum-conversion] reports > an error when it is assigned to field_types which is also an enum, argtypes. > > To avoid that, convert "size" to "int" in MK_ARRAY(). "int" is the type > used for the size evaluation in thunk_type_size(). > > Signed-off-by: Laurent Vivier <laurent@vivier.eu> > --- > include/exec/user/thunk.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h > index a5bbb2c73331..b798fcb69cf4 100644 > --- a/include/exec/user/thunk.h > +++ b/include/exec/user/thunk.h > @@ -42,7 +42,7 @@ typedef enum argtype { > } argtype; > > #define MK_PTR(type) TYPE_PTR, type > -#define MK_ARRAY(type, size) TYPE_ARRAY, size, type > +#define MK_ARRAY(type, size) TYPE_ARRAY, (int)size, type You need to use parenthesis: #define MK_ARRAY(type, size) TYPE_ARRAY, (int)(size), type See: MK_ARRAY(TYPE_CHAR, USBDEVFS_MAXDRIVERNAME + 1)) /* driver */ While here I'd also add them to 'type'. With parenthesis: Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > #define MK_STRUCT(id) TYPE_STRUCT, id > > #define THUNK_TARGET 0 >
diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index a5bbb2c73331..b798fcb69cf4 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -42,7 +42,7 @@ typedef enum argtype { } argtype; #define MK_PTR(type) TYPE_PTR, type -#define MK_ARRAY(type, size) TYPE_ARRAY, size, type +#define MK_ARRAY(type, size) TYPE_ARRAY, (int)size, type #define MK_STRUCT(id) TYPE_STRUCT, id #define THUNK_TARGET 0
MK_ARRAY(type,size) is used to fill the field_types buffer, and if the "size" parameter is an enum type, clang [-Werror,-Wenum-conversion] reports an error when it is assigned to field_types which is also an enum, argtypes. To avoid that, convert "size" to "int" in MK_ARRAY(). "int" is the type used for the size evaluation in thunk_type_size(). Signed-off-by: Laurent Vivier <laurent@vivier.eu> --- include/exec/user/thunk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)