Replace a single element array with a single element field.
This fixes the following cocci warning:
drivers/media/common/siano/smscoreapi.h:619:5-13: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/common/siano/smscoreapi.c | 10 +++++-----
drivers/media/common/siano/smscoreapi.h | 2 +-
drivers/media/common/siano/smsdvb-main.c | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index 7ebcb10126c9..b6f1eb5dbbdf 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -839,7 +839,7 @@ static int smscore_configure_board(struct smscore_device_t *coredev)
mtu_msg.x_msg_header.msg_flags = 0;
mtu_msg.x_msg_header.msg_type = MSG_SMS_SET_MAX_TX_MSG_LEN_REQ;
mtu_msg.x_msg_header.msg_length = sizeof(mtu_msg);
- mtu_msg.msg_data[0] = board->mtu;
+ mtu_msg.msg_data = board->mtu;
coredev->sendrequest_handler(coredev->context, &mtu_msg,
sizeof(mtu_msg));
@@ -852,7 +852,7 @@ static int smscore_configure_board(struct smscore_device_t *coredev)
SMS_INIT_MSG(&crys_msg.x_msg_header,
MSG_SMS_NEW_CRYSTAL_REQ,
sizeof(crys_msg));
- crys_msg.msg_data[0] = board->crystal;
+ crys_msg.msg_data = board->crystal;
coredev->sendrequest_handler(coredev->context, &crys_msg,
sizeof(crys_msg));
@@ -1306,7 +1306,7 @@ static int smscore_init_device(struct smscore_device_t *coredev, int mode)
msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer);
SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
sizeof(struct sms_msg_data));
- msg->msg_data[0] = mode;
+ msg->msg_data = mode;
rc = smscore_sendrequest_and_wait(coredev, msg,
msg->x_msg_header. msg_length,
@@ -1394,7 +1394,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
sizeof(struct sms_msg_data));
- msg->msg_data[0] = mode;
+ msg->msg_data = mode;
rc = smscore_sendrequest_and_wait(
coredev, msg, msg->x_msg_header.msg_length,
@@ -1554,7 +1554,7 @@ void smscore_onresponse(struct smscore_device_t *coredev,
struct sms_msg_data *validity = (struct sms_msg_data *) phdr;
pr_debug("MSG_SMS_DATA_VALIDITY_RES, checksum = 0x%x\n",
- validity->msg_data[0]);
+ validity->msg_data);
complete(&coredev->data_validity_done);
break;
}
diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h
index f8789ee0d554..46dc74ac9318 100644
--- a/drivers/media/common/siano/smscoreapi.h
+++ b/drivers/media/common/siano/smscoreapi.h
@@ -616,7 +616,7 @@ struct sms_msg_hdr {
struct sms_msg_data {
struct sms_msg_hdr x_msg_header;
- u32 msg_data[1];
+ u32 msg_data;
};
struct sms_msg_data2 {
diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
index d893a0e4672b..44d8fe8b220e 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -689,7 +689,7 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed)
pid_msg.x_msg_header.msg_flags = 0;
pid_msg.x_msg_header.msg_type = MSG_SMS_ADD_PID_FILTER_REQ;
pid_msg.x_msg_header.msg_length = sizeof(pid_msg);
- pid_msg.msg_data[0] = feed->pid;
+ pid_msg.msg_data = feed->pid;
return smsclient_sendrequest(client->smsclient,
&pid_msg, sizeof(pid_msg));
@@ -711,7 +711,7 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
pid_msg.x_msg_header.msg_flags = 0;
pid_msg.x_msg_header.msg_type = MSG_SMS_REMOVE_PID_FILTER_REQ;
pid_msg.x_msg_header.msg_length = sizeof(pid_msg);
- pid_msg.msg_data[0] = feed->pid;
+ pid_msg.msg_data = feed->pid;
return smsclient_sendrequest(client->smsclient,
&pid_msg, sizeof(pid_msg));
--
2.45.0.rc1.225.g2a3ae87e7f-goog
Hi Ricardo,
kernel test robot noticed the following build errors:
[auto build test ERROR on e695668af8523b059127dfa8b261c76e7c9cde10]
url: https://github.com/intel-lab-lkp/linux/commits/Ricardo-Ribalda/media-allegro-nal-hevc-Refactor-nal_hevc_sub_layer_hrd_parameters/20240507-213119
base: e695668af8523b059127dfa8b261c76e7c9cde10
patch link: https://lore.kernel.org/r/20240507-cocci-flexarray-v1-6-4a421c21fd06%40chromium.org
patch subject: [PATCH 06/18] media: siano: Refactor struct sms_msg_data
config: mips-randconfig-r113-20240508 (https://download.01.org/0day-ci/archive/20240508/202405081007.7eCrDhSN-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 0ab4458df0688955620b72cc2c72a32dffad3615)
reproduce: (https://download.01.org/0day-ci/archive/20240508/202405081007.7eCrDhSN-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405081007.7eCrDhSN-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from drivers/media/common/siano/smsendian.c:15:
In file included from drivers/media/common/siano/smscoreapi.h:18:
In file included from include/linux/mm.h:2208:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
>> drivers/media/common/siano/smsendian.c:27:16: error: subscripted value is not an array, pointer, or vector
27 | msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0]));
| ~~~~~~~~~~~~~^~
drivers/media/common/siano/smsendian.c:27:64: error: subscripted value is not an array, pointer, or vector
27 | msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0]));
| ~~~~~~~~~~~~~^~
include/linux/byteorder/generic.h:89:21: note: expanded from macro 'le32_to_cpu'
89 | #define le32_to_cpu __le32_to_cpu
| ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
drivers/media/common/siano/smsendian.c:36:17: error: subscripted value is not an array, pointer, or vector
36 | msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
| ~~~~~~~~~~~~~^~
drivers/media/common/siano/smsendian.c:36:64: error: subscripted value is not an array, pointer, or vector
36 | msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
| ~~~~~~~~~~~~~^~
include/linux/byteorder/generic.h:89:21: note: expanded from macro 'le32_to_cpu'
89 | #define le32_to_cpu __le32_to_cpu
| ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
drivers/media/common/siano/smsendian.c:73:17: error: subscripted value is not an array, pointer, or vector
73 | msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
| ~~~~~~~~~~~~~^~
drivers/media/common/siano/smsendian.c:73:64: error: subscripted value is not an array, pointer, or vector
73 | msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
| ~~~~~~~~~~~~~^~
include/linux/byteorder/generic.h:89:21: note: expanded from macro 'le32_to_cpu'
89 | #define le32_to_cpu __le32_to_cpu
| ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
1 warning and 6 errors generated.
vim +27 drivers/media/common/siano/smsendian.c
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 13
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 14 #include "smsendian.h"
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 @15 #include "smscoreapi.h"
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 16
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 17 void smsendian_handle_tx_message(void *buffer)
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 18 {
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 19 #ifdef __BIG_ENDIAN
ff7ff3656465f7 drivers/media/common/siano/smsendian.c Dong Chuanjian 2022-12-26 20 struct sms_msg_data *msg = buffer;
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 21 int i;
28a59df4d7cb8f drivers/media/common/siano/smsendian.c Mauro Carvalho Chehab 2013-03-21 22 int msg_words;
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 23
dfef84fc135832 drivers/media/common/siano/smsendian.c Mauro Carvalho Chehab 2013-03-21 24 switch (msg->x_msg_header.msg_type) {
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 25 case MSG_SMS_DATA_DOWNLOAD_REQ:
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 26 {
e1b7f11b37def5 drivers/media/common/siano/smsendian.c Mauro Carvalho Chehab 2018-04-20 @27 msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0]));
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 28 break;
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 29 }
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 30
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 31 default:
28a59df4d7cb8f drivers/media/common/siano/smsendian.c Mauro Carvalho Chehab 2013-03-21 32 msg_words = (msg->x_msg_header.msg_length -
dfef84fc135832 drivers/media/common/siano/smsendian.c Mauro Carvalho Chehab 2013-03-21 33 sizeof(struct sms_msg_hdr))/4;
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 34
28a59df4d7cb8f drivers/media/common/siano/smsendian.c Mauro Carvalho Chehab 2013-03-21 35 for (i = 0; i < msg_words; i++)
e1b7f11b37def5 drivers/media/common/siano/smsendian.c Mauro Carvalho Chehab 2018-04-20 36 msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 37
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 38 break;
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 39 }
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 40 #endif /* __BIG_ENDIAN */
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 41 }
2c5582e58ce298 drivers/media/dvb/siano/smsendian.c Mauro Carvalho Chehab 2009-05-14 42 EXPORT_SYMBOL_GPL(smsendian_handle_tx_message);
cb17f9047d2c6f drivers/media/dvb/siano/smsendian.c Uri Shkolnik 2009-04-20 43
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi,
The CI has found a build error in ppc for this patch.
https://gitlab.freedesktop.org/linux-media/media-staging/-/pipelines/1171798/test_report?job_name=build
Will send a v2 shortly
On Tue, 7 May 2024 at 15:18, Ricardo Ribalda <ribalda@chromium.org> wrote:
>
> Replace a single element array with a single element field.
>
> This fixes the following cocci warning:
> drivers/media/common/siano/smscoreapi.h:619:5-13: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/common/siano/smscoreapi.c | 10 +++++-----
> drivers/media/common/siano/smscoreapi.h | 2 +-
> drivers/media/common/siano/smsdvb-main.c | 4 ++--
> 3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
> index 7ebcb10126c9..b6f1eb5dbbdf 100644
> --- a/drivers/media/common/siano/smscoreapi.c
> +++ b/drivers/media/common/siano/smscoreapi.c
> @@ -839,7 +839,7 @@ static int smscore_configure_board(struct smscore_device_t *coredev)
> mtu_msg.x_msg_header.msg_flags = 0;
> mtu_msg.x_msg_header.msg_type = MSG_SMS_SET_MAX_TX_MSG_LEN_REQ;
> mtu_msg.x_msg_header.msg_length = sizeof(mtu_msg);
> - mtu_msg.msg_data[0] = board->mtu;
> + mtu_msg.msg_data = board->mtu;
>
> coredev->sendrequest_handler(coredev->context, &mtu_msg,
> sizeof(mtu_msg));
> @@ -852,7 +852,7 @@ static int smscore_configure_board(struct smscore_device_t *coredev)
> SMS_INIT_MSG(&crys_msg.x_msg_header,
> MSG_SMS_NEW_CRYSTAL_REQ,
> sizeof(crys_msg));
> - crys_msg.msg_data[0] = board->crystal;
> + crys_msg.msg_data = board->crystal;
>
> coredev->sendrequest_handler(coredev->context, &crys_msg,
> sizeof(crys_msg));
> @@ -1306,7 +1306,7 @@ static int smscore_init_device(struct smscore_device_t *coredev, int mode)
> msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer);
> SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
> sizeof(struct sms_msg_data));
> - msg->msg_data[0] = mode;
> + msg->msg_data = mode;
>
> rc = smscore_sendrequest_and_wait(coredev, msg,
> msg->x_msg_header. msg_length,
> @@ -1394,7 +1394,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
>
> SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
> sizeof(struct sms_msg_data));
> - msg->msg_data[0] = mode;
> + msg->msg_data = mode;
>
> rc = smscore_sendrequest_and_wait(
> coredev, msg, msg->x_msg_header.msg_length,
> @@ -1554,7 +1554,7 @@ void smscore_onresponse(struct smscore_device_t *coredev,
> struct sms_msg_data *validity = (struct sms_msg_data *) phdr;
>
> pr_debug("MSG_SMS_DATA_VALIDITY_RES, checksum = 0x%x\n",
> - validity->msg_data[0]);
> + validity->msg_data);
> complete(&coredev->data_validity_done);
> break;
> }
> diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h
> index f8789ee0d554..46dc74ac9318 100644
> --- a/drivers/media/common/siano/smscoreapi.h
> +++ b/drivers/media/common/siano/smscoreapi.h
> @@ -616,7 +616,7 @@ struct sms_msg_hdr {
>
> struct sms_msg_data {
> struct sms_msg_hdr x_msg_header;
> - u32 msg_data[1];
> + u32 msg_data;
> };
>
> struct sms_msg_data2 {
> diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
> index d893a0e4672b..44d8fe8b220e 100644
> --- a/drivers/media/common/siano/smsdvb-main.c
> +++ b/drivers/media/common/siano/smsdvb-main.c
> @@ -689,7 +689,7 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed)
> pid_msg.x_msg_header.msg_flags = 0;
> pid_msg.x_msg_header.msg_type = MSG_SMS_ADD_PID_FILTER_REQ;
> pid_msg.x_msg_header.msg_length = sizeof(pid_msg);
> - pid_msg.msg_data[0] = feed->pid;
> + pid_msg.msg_data = feed->pid;
>
> return smsclient_sendrequest(client->smsclient,
> &pid_msg, sizeof(pid_msg));
> @@ -711,7 +711,7 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
> pid_msg.x_msg_header.msg_flags = 0;
> pid_msg.x_msg_header.msg_type = MSG_SMS_REMOVE_PID_FILTER_REQ;
> pid_msg.x_msg_header.msg_length = sizeof(pid_msg);
> - pid_msg.msg_data[0] = feed->pid;
> + pid_msg.msg_data = feed->pid;
>
> return smsclient_sendrequest(client->smsclient,
> &pid_msg, sizeof(pid_msg));
>
> --
> 2.45.0.rc1.225.g2a3ae87e7f-goog
>
--
Ricardo Ribalda
© 2016 - 2026 Red Hat, Inc.