[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1c640c3d-c5db-4eb7-8a22-6d9886a1412a@stanley.mountain>
Date: Sat, 24 Aug 2024 14:21:47 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Abhishek Tamboli <abhishektamboli9@...il.com>
Cc: gregkh@...uxfoundation.org, tdavies@...kphysics.net,
philipp.g.hortmann@...il.com, garyrookard@...tmail.org,
linux-staging@...ts.linux.dev, skhan@...uxfoundation.org,
rbmarliere@...il.com, christophe.jaillet@...adoo.fr,
linux-kernel-mentees@...ts.linuxfoundation.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] staging: rtl8192e: Replace strcpy with strcat in
rtl819x_translate_scan
On Fri, Aug 23, 2024 at 09:04:11PM +0530, Abhishek Tamboli wrote:
> diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
> index fbd4ec824084..ec0c4c5bade7 100644
> --- a/drivers/staging/rtl8192e/rtllib_wx.c
> +++ b/drivers/staging/rtl8192e/rtllib_wx.c
> @@ -23,14 +23,14 @@ static const char * const rtllib_modes[] = {
> };
>
> #define MAX_CUSTOM_LEN 64
> +#define MAX_PROTO_NAME_LEN 10
> static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
> char *start, char *stop,
> struct rtllib_network *network,
> struct iw_request_info *info)
> {
> char custom[MAX_CUSTOM_LEN];
> - char proto_name[6];
> - char *pname = proto_name;
> + char proto_name[MAX_PROTO_NAME_LEN];
In the end I think we don't want to make this buffer larger. But if we did
this define is really vague and slightly confusing. I assumed it was something
else when I read it. It hurts readability. It would probably be better to just
leave it as 6 instead and add a comment. /* Large enough to hold "N-24G" */
> char *p;
> struct iw_event iwe;
> int i, j;
> @@ -59,13 +59,12 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
> }
> /* Add the protocol name */
> iwe.cmd = SIOCGIWNAME;
> + /* Initialise proto_name as an empty string*/
This comment doesn't add any information. Every kernel developer knows what
memset() does.
> + memset(proto_name, '\0', sizeof(proto_name));
Normally we would just say 0 instead of '\0'. The other way to do this would
be to initialize it at the start:
char proto_name[6] = "";
regards,
dan carpenter
Powered by blists - more mailing lists