* [PATCH] uvc_driver: Error Fix in the file drivers/media/usb/uvc/uvc_driver.c
@ 2023-09-03 9:54 fasih0001
2023-09-03 20:59 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: fasih0001 @ 2023-09-03 9:54 UTC (permalink / raw)
To: laurent.pinchart, mchehab; +Cc: linux-media, linux-kernel, Fasih
From: Fasih <fasih0001@gmail.com>
Error fix for the line 2429 and 2430, The error message indicated that "Macros with complex values should be enclosed in parentheses".
This typically means that the macro is defined in a way that involves complex expressions or compound literals,
and the preprocessor requires them to be enclosed in parentheses for clarity and proper evaluation.
To address this error and comply with the requirement to enclose complex values in parentheses,
you should wrap the entire expression inside an extra set of parentheses.
Signed-off-by: Syed Muhammad Fasih Ul Hassan <fasih0001@gmail.com>
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2095,6 +2095,8 @@ static int uvc_probe(struct usb_interface *intf,
int function;
int ret;
+ pr_info("I changed uvcvideo driver in the Linux Kernel\n");
+
/* Allocate memory for the device and initialize it. */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL)
@@ -2417,9 +2419,9 @@ static const struct uvc_device_info uvc_quirk_force_y8 = {
.quirks = UVC_QUIRK_FORCE_Y8,
};
-#define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q}
-#define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \
- {.meta_format = m}
+#define UVC_INFO_QUIRK(q) ((kernel_ulong_t)&(struct uvc_device_info){.quirks = q})
+#define UVC_INFO_META(m) ((kernel_ulong_t)&(struct uvc_device_info) \
+ {.meta_format = m})
---
drivers/media/usb/uvc/uvc_driver.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 08fcd2ffa727..42d42b211094 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2095,6 +2095,8 @@ static int uvc_probe(struct usb_interface *intf,
int function;
int ret;
+ pr_info("I changed uvcvideo driver in the Linux Kernel\n");
+
/* Allocate memory for the device and initialize it. */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL)
@@ -2417,9 +2419,16 @@ static const struct uvc_device_info uvc_quirk_force_y8 = {
.quirks = UVC_QUIRK_FORCE_Y8,
};
-#define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q}
-#define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \
- {.meta_format = m}
+/* For line 2429 and 2430, The error message indicated that "Macros with complex values should be enclosed in parentheses".
+ * This typically means that the macro is defined in a way that involves complex expressions or compound literals,
+ * and the preprocessor requires them to be enclosed in parentheses for clarity and proper evaluation.
+ * To address this error and comply with the requirement to enclose complex values in parentheses,
+ * you should wrap the entire expression inside an extra set of parentheses like that:
+ * #define UVC_INFO_QUIRK(q) ((kernel_ulong_t)&(struct uvc_device_info){.quirks = q})
+ */
+#define UVC_INFO_QUIRK(q) ((kernel_ulong_t)&(struct uvc_device_info){.quirks = q})
+#define UVC_INFO_META(m) ((kernel_ulong_t)&(struct uvc_device_info) \
+ {.meta_format = m})
/*
* The Logitech cameras listed below have their interface class set to
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] uvc_driver: Error Fix in the file drivers/media/usb/uvc/uvc_driver.c
2023-09-03 9:54 [PATCH] uvc_driver: Error Fix in the file drivers/media/usb/uvc/uvc_driver.c fasih0001
@ 2023-09-03 20:59 ` Laurent Pinchart
2023-09-04 9:45 ` [PATCH] usb: uvc: Fix macro in uvc_driver.c for complex values fasih0001
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2023-09-03 20:59 UTC (permalink / raw)
To: fasih0001; +Cc: mchehab, linux-media, linux-kernel
Hello,
On Sun, Sep 03, 2023 at 02:54:31PM +0500, fasih0001@gmail.com wrote:
> From: Fasih <fasih0001@gmail.com>
>
> Error fix for the line 2429 and 2430, The error message indicated that "Macros with complex values should be enclosed in parentheses".
> This typically means that the macro is defined in a way that involves complex expressions or compound literals,
> and the preprocessor requires them to be enclosed in parentheses for clarity and proper evaluation.
> To address this error and comply with the requirement to enclose complex values in parentheses,
> you should wrap the entire expression inside an extra set of parentheses.
Did you read Documentation/process/submitting-patches.rst ?
> Signed-off-by: Syed Muhammad Fasih Ul Hassan <fasih0001@gmail.com>
>
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -2095,6 +2095,8 @@ static int uvc_probe(struct usb_interface *intf,
> int function;
> int ret;
>
> + pr_info("I changed uvcvideo driver in the Linux Kernel\n");
> +
Have you read our patch before sending it out ?
> /* Allocate memory for the device and initialize it. */
> dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> if (dev == NULL)
> @@ -2417,9 +2419,9 @@ static const struct uvc_device_info uvc_quirk_force_y8 = {
> .quirks = UVC_QUIRK_FORCE_Y8,
> };
>
> -#define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q}
> -#define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \
> - {.meta_format = m}
> +#define UVC_INFO_QUIRK(q) ((kernel_ulong_t)&(struct uvc_device_info){.quirks = q})
> +#define UVC_INFO_META(m) ((kernel_ulong_t)&(struct uvc_device_info) \
> + {.meta_format = m})
Why do you think this is a good change ?
> ---
> drivers/media/usb/uvc/uvc_driver.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
Your patch seems corrupted.
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index 08fcd2ffa727..42d42b211094 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -2095,6 +2095,8 @@ static int uvc_probe(struct usb_interface *intf,
> int function;
> int ret;
>
> + pr_info("I changed uvcvideo driver in the Linux Kernel\n");
> +
> /* Allocate memory for the device and initialize it. */
> dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> if (dev == NULL)
> @@ -2417,9 +2419,16 @@ static const struct uvc_device_info uvc_quirk_force_y8 = {
> .quirks = UVC_QUIRK_FORCE_Y8,
> };
>
> -#define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q}
> -#define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \
> - {.meta_format = m}
> +/* For line 2429 and 2430, The error message indicated that "Macros with complex values should be enclosed in parentheses".
> + * This typically means that the macro is defined in a way that involves complex expressions or compound literals,
> + * and the preprocessor requires them to be enclosed in parentheses for clarity and proper evaluation.
> + * To address this error and comply with the requirement to enclose complex values in parentheses,
> + * you should wrap the entire expression inside an extra set of parentheses like that:
> + * #define UVC_INFO_QUIRK(q) ((kernel_ulong_t)&(struct uvc_device_info){.quirks = q})
> + */
> +#define UVC_INFO_QUIRK(q) ((kernel_ulong_t)&(struct uvc_device_info){.quirks = q})
> +#define UVC_INFO_META(m) ((kernel_ulong_t)&(struct uvc_device_info) \
> + {.meta_format = m})
>
> /*
> * The Logitech cameras listed below have their interface class set to
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] usb: uvc: Fix macro in uvc_driver.c for complex values
2023-09-03 20:59 ` Laurent Pinchart
@ 2023-09-04 9:45 ` fasih0001
0 siblings, 0 replies; 3+ messages in thread
From: fasih0001 @ 2023-09-04 9:45 UTC (permalink / raw)
Cc: mchehab, linux-media, linux-kernel, Fasih
From: Fasih <fasih0001@gmail.com>
The macro UVC_INFO_QUIRK(q) in uvc_driver.c initializes a structure
using a compound literal, and the complex value within the macro was
not properly enclosed in parentheses. This could lead to operator
precedence issues and reduced code clarity.
This commit adds an extra set of parentheses to the macro definition
to ensure correct evaluation and adherence to best practices. This
change also improves code readability and portability.
Signed-off-by: Syed Muhammad Fasih Ul Hassan <fasih0001@gmail.com>
Signed-off-by: Fasih <fasih0001@gmail.com>
---
drivers/media/usb/uvc/uvc_driver.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 08fcd2ffa727..63999f1c8d55 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2417,9 +2417,9 @@ static const struct uvc_device_info uvc_quirk_force_y8 = {
.quirks = UVC_QUIRK_FORCE_Y8,
};
-#define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q}
-#define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \
- {.meta_format = m}
+#define UVC_INFO_QUIRK(q) ((kernel_ulong_t)&(struct uvc_device_info){.quirks = q})
+#define UVC_INFO_META(m) ((kernel_ulong_t)&(struct uvc_device_info) \
+ {.meta_format = m})
/*
* The Logitech cameras listed below have their interface class set to
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-04 9:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-03 9:54 [PATCH] uvc_driver: Error Fix in the file drivers/media/usb/uvc/uvc_driver.c fasih0001
2023-09-03 20:59 ` Laurent Pinchart
2023-09-04 9:45 ` [PATCH] usb: uvc: Fix macro in uvc_driver.c for complex values fasih0001
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox