diff mbox series

[PATCHv2,12/23] media: v4l2-subdev.h: increase struct v4l2_subdev name size

Message ID 20230923152107.283289-13-hverkuil-cisco@xs4all.nl (mailing list archive)
State New, archived
Headers show
Series media: fix all string truncate warnings | expand

Commit Message

Hans Verkuil Sept. 23, 2023, 3:20 p.m. UTC
This resolves a lot of the string truncate compiler warnings.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/staging/media/omap4iss/iss_csi2.c | 2 +-
 include/media/v4l2-subdev.h               | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart Sept. 23, 2023, 6:11 p.m. UTC | #1
Hi Hans,

Thank you for the patch.

On Sat, Sep 23, 2023 at 05:20:56PM +0200, Hans Verkuil wrote:
> This resolves a lot of the string truncate compiler warnings.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/staging/media/omap4iss/iss_csi2.c | 2 +-
>  include/media/v4l2-subdev.h               | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c
> index 04ce0e7eb557..d2844414de4f 100644
> --- a/drivers/staging/media/omap4iss/iss_csi2.c
> +++ b/drivers/staging/media/omap4iss/iss_csi2.c
> @@ -1260,7 +1260,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
>  	struct media_pad *pads = csi2->pads;
>  	struct media_entity *me = &sd->entity;
>  	int ret;
> -	char name[V4L2_SUBDEV_NAME_SIZE];
> +	char name[32];
>  
>  	v4l2_subdev_init(sd, &csi2_ops);
>  	sd->internal_ops = &csi2_internal_ops;
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index 5f59ff0796b7..5711354056b9 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -951,7 +951,7 @@ struct v4l2_subdev_internal_ops {
>  	void (*release)(struct v4l2_subdev *sd);
>  };
>  
> -#define V4L2_SUBDEV_NAME_SIZE 32
> +#define V4L2_SUBDEV_NAME_SIZE 52

Can we allocate it dynamically instead ?

>  
>  /* Set this flag if this subdev is a i2c device. */
>  #define V4L2_SUBDEV_FL_IS_I2C			(1U << 0)
Hans Verkuil Sept. 25, 2023, 6:26 a.m. UTC | #2
On 23/09/2023 20:11, Laurent Pinchart wrote:
> Hi Hans,
> 
> Thank you for the patch.
> 
> On Sat, Sep 23, 2023 at 05:20:56PM +0200, Hans Verkuil wrote:
>> This resolves a lot of the string truncate compiler warnings.
>>
>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>> ---
>>  drivers/staging/media/omap4iss/iss_csi2.c | 2 +-
>>  include/media/v4l2-subdev.h               | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c
>> index 04ce0e7eb557..d2844414de4f 100644
>> --- a/drivers/staging/media/omap4iss/iss_csi2.c
>> +++ b/drivers/staging/media/omap4iss/iss_csi2.c
>> @@ -1260,7 +1260,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
>>  	struct media_pad *pads = csi2->pads;
>>  	struct media_entity *me = &sd->entity;
>>  	int ret;
>> -	char name[V4L2_SUBDEV_NAME_SIZE];
>> +	char name[32];
>>  
>>  	v4l2_subdev_init(sd, &csi2_ops);
>>  	sd->internal_ops = &csi2_internal_ops;
>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>> index 5f59ff0796b7..5711354056b9 100644
>> --- a/include/media/v4l2-subdev.h
>> +++ b/include/media/v4l2-subdev.h
>> @@ -951,7 +951,7 @@ struct v4l2_subdev_internal_ops {
>>  	void (*release)(struct v4l2_subdev *sd);
>>  };
>>  
>> -#define V4L2_SUBDEV_NAME_SIZE 32
>> +#define V4L2_SUBDEV_NAME_SIZE 52
> 
> Can we allocate it dynamically instead ?

Anything is possible :-)

But that's a separate issue and, I think, should be part of a larger
uAPI discussion. Right now it is just to squash those annoying warnings.

Regards,

	Hans

> 
>>  
>>  /* Set this flag if this subdev is a i2c device. */
>>  #define V4L2_SUBDEV_FL_IS_I2C			(1U << 0)
>
Arnd Bergmann Sept. 25, 2023, 6:51 a.m. UTC | #3
On Mon, Sep 25, 2023, at 08:26, Hans Verkuil wrote:
> On 23/09/2023 20:11, Laurent Pinchart wrote:
>>>  
>>> -#define V4L2_SUBDEV_NAME_SIZE 32
>>> +#define V4L2_SUBDEV_NAME_SIZE 52
>> 
>> Can we allocate it dynamically instead ?
>
> Anything is possible :-)
>
> But that's a separate issue and, I think, should be part of a larger
> uAPI discussion. Right now it is just to squash those annoying warnings.

Agreed, and I don't think that dynamic allocation here would
help either on saving memory (because of the slab overhead) or
for correctness (making it even harder for uapi to if there is no
upper bound on the name length).

   Arnd
diff mbox series

Patch

diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c
index 04ce0e7eb557..d2844414de4f 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.c
+++ b/drivers/staging/media/omap4iss/iss_csi2.c
@@ -1260,7 +1260,7 @@  static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
 	struct media_pad *pads = csi2->pads;
 	struct media_entity *me = &sd->entity;
 	int ret;
-	char name[V4L2_SUBDEV_NAME_SIZE];
+	char name[32];
 
 	v4l2_subdev_init(sd, &csi2_ops);
 	sd->internal_ops = &csi2_internal_ops;
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 5f59ff0796b7..5711354056b9 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -951,7 +951,7 @@  struct v4l2_subdev_internal_ops {
 	void (*release)(struct v4l2_subdev *sd);
 };
 
-#define V4L2_SUBDEV_NAME_SIZE 32
+#define V4L2_SUBDEV_NAME_SIZE 52
 
 /* Set this flag if this subdev is a i2c device. */
 #define V4L2_SUBDEV_FL_IS_I2C			(1U << 0)