* checkpatch potential false positive
@ 2017-11-06 4:19 Tobin C. Harding
2017-11-06 8:33 ` Andy Whitcroft
0 siblings, 1 reply; 4+ messages in thread
From: Tobin C. Harding @ 2017-11-06 4:19 UTC (permalink / raw)
To: Andy Whitcroft, Joe Perches; +Cc: linux-kernel
Hi,
When parsing drivers/staging/unisys/visorbus/visorchipset.c in Greg's
staging tree checkpatch emits
--------------
visorchipset.c
--------------
WARNING: char * array declaration might be better as static const
#1050: FILE: visorchipset.c:1050:
+ char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev,
WARNING: char * array declaration might be better as static const
#1140: FILE: visorchipset.c:1140:
+ char *envp[] = { env_selftest, NULL };
total: 0 errors, 2 warnings, 1694 lines checked
I may be wrong but I think the code in question is clean and
correct. Since checkpatch is saying this _might_ be better ... perhaps
checkpatch could emit CHECK instead of WARNING for this?
Here is the complete function to save finding the file.
/*
* parahotplug_request_kickoff() - initiate parahotplug request
* @req: the request to initiate
*
* Cause uevent to run the user level script to do the disable/enable specified
* in the parahotplug_request.
*/
static int parahotplug_request_kickoff(struct parahotplug_request *req)
{
struct controlvm_message_packet *cmd = &req->msg.cmd;
char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
env_func[40];
char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev,
env_func, NULL
};
sprintf(env_cmd, "VISOR_PARAHOTPLUG=1");
sprintf(env_id, "VISOR_PARAHOTPLUG_ID=%d", req->id);
sprintf(env_state, "VISOR_PARAHOTPLUG_STATE=%d",
cmd->device_change_state.state.active);
sprintf(env_bus, "VISOR_PARAHOTPLUG_BUS=%d",
cmd->device_change_state.bus_no);
sprintf(env_dev, "VISOR_PARAHOTPLUG_DEVICE=%d",
cmd->device_change_state.dev_no >> 3);
sprintf(env_func, "VISOR_PARAHOTPLUG_FUNCTION=%d",
cmd->device_change_state.dev_no & 0x7);
return kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj,
KOBJ_CHANGE, envp);
}
If this is not the sort of bug report you like, could you please (if you
have time) school me on how to better report such things in the future.
thanks,
Tobin.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: checkpatch potential false positive
2017-11-06 4:19 checkpatch potential false positive Tobin C. Harding
@ 2017-11-06 8:33 ` Andy Whitcroft
2017-11-06 15:29 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Andy Whitcroft @ 2017-11-06 8:33 UTC (permalink / raw)
To: Tobin C. Harding; +Cc: Joe Perches, linux-kernel
On Mon, Nov 06, 2017 at 03:19:14PM +1100, Tobin C. Harding wrote:
> Hi,
>
> When parsing drivers/staging/unisys/visorbus/visorchipset.c in Greg's
> staging tree checkpatch emits
>
> --------------
> visorchipset.c
> --------------
> WARNING: char * array declaration might be better as static const
> #1050: FILE: visorchipset.c:1050:
> + char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev,
>
> WARNING: char * array declaration might be better as static const
> #1140: FILE: visorchipset.c:1140:
> + char *envp[] = { env_selftest, NULL };
>
> total: 0 errors, 2 warnings, 1694 lines checked
>
> I may be wrong but I think the code in question is clean and
> correct. Since checkpatch is saying this _might_ be better ... perhaps
> checkpatch could emit CHECK instead of WARNING for this?
>
> Here is the complete function to save finding the file.
>
> /*
> * parahotplug_request_kickoff() - initiate parahotplug request
> * @req: the request to initiate
> *
> * Cause uevent to run the user level script to do the disable/enable specified
> * in the parahotplug_request.
> */
> static int parahotplug_request_kickoff(struct parahotplug_request *req)
> {
> struct controlvm_message_packet *cmd = &req->msg.cmd;
> char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
> env_func[40];
> char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev,
> env_func, NULL
> };
>
> sprintf(env_cmd, "VISOR_PARAHOTPLUG=1");
> sprintf(env_id, "VISOR_PARAHOTPLUG_ID=%d", req->id);
> sprintf(env_state, "VISOR_PARAHOTPLUG_STATE=%d",
> cmd->device_change_state.state.active);
> sprintf(env_bus, "VISOR_PARAHOTPLUG_BUS=%d",
> cmd->device_change_state.bus_no);
> sprintf(env_dev, "VISOR_PARAHOTPLUG_DEVICE=%d",
> cmd->device_change_state.dev_no >> 3);
> sprintf(env_func, "VISOR_PARAHOTPLUG_FUNCTION=%d",
> cmd->device_change_state.dev_no & 0x7);
> return kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj,
> KOBJ_CHANGE, envp);
> }
>
> If this is not the sort of bug report you like, could you please (if you
> have time) school me on how to better report such things in the future.
>
> thanks,
> Tobin.
I'll let Joe talk to whether this ought to be a CHECK.
The function there looks to never modify the envp pointer so some kind
of const might well be reasonable as you do not update the pointers.
Right?
-apw
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: checkpatch potential false positive
2017-11-06 8:33 ` Andy Whitcroft
@ 2017-11-06 15:29 ` Joe Perches
2017-11-06 20:54 ` Tobin C. Harding
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2017-11-06 15:29 UTC (permalink / raw)
To: Andy Whitcroft, Tobin C. Harding; +Cc: linux-kernel
On Mon, 2017-11-06 at 08:33 +0000, Andy Whitcroft wrote:
> On Mon, Nov 06, 2017 at 03:19:14PM +1100, Tobin C. Harding wrote:
> > Hi,
Hello.
> > When parsing drivers/staging/unisys/visorbus/visorchipset.c in Greg's
> > staging tree checkpatch emits
> >
> > --------------
> > visorchipset.c
> > --------------
> > WARNING: char * array declaration might be better as static const
> > #1050: FILE: visorchipset.c:1050:
> > + char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev,
> >
> > WARNING: char * array declaration might be better as static const
> > #1140: FILE: visorchipset.c:1140:
> > + char *envp[] = { env_selftest, NULL };
> >
> > total: 0 errors, 2 warnings, 1694 lines checked
> >
> > I may be wrong but I think the code in question is clean and
> > correct. Since checkpatch is saying this _might_ be better ... perhaps
> > checkpatch could emit CHECK instead of WARNING for this?
CHECKs aren't enabled by default except for a few
directories and this warning is much more commonly
correct than incorrect.
checkpatch will always have both false positives and
false negatives. It's stupid, people generally aren't.
Just ignore checkpatch bleats that aren't appropriate.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: checkpatch potential false positive
2017-11-06 15:29 ` Joe Perches
@ 2017-11-06 20:54 ` Tobin C. Harding
0 siblings, 0 replies; 4+ messages in thread
From: Tobin C. Harding @ 2017-11-06 20:54 UTC (permalink / raw)
To: Joe Perches; +Cc: Andy Whitcroft, linux-kernel
On Mon, Nov 06, 2017 at 07:29:18AM -0800, Joe Perches wrote:
> On Mon, 2017-11-06 at 08:33 +0000, Andy Whitcroft wrote:
> > On Mon, Nov 06, 2017 at 03:19:14PM +1100, Tobin C. Harding wrote:
> > > Hi,
>
> Hello.
>
> > > When parsing drivers/staging/unisys/visorbus/visorchipset.c in Greg's
> > > staging tree checkpatch emits
> > >
> > > --------------
> > > visorchipset.c
> > > --------------
> > > WARNING: char * array declaration might be better as static const
> > > #1050: FILE: visorchipset.c:1050:
> > > + char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev,
> > >
> > > WARNING: char * array declaration might be better as static const
> > > #1140: FILE: visorchipset.c:1140:
> > > + char *envp[] = { env_selftest, NULL };
> > >
> > > total: 0 errors, 2 warnings, 1694 lines checked
> > >
> > > I may be wrong but I think the code in question is clean and
> > > correct. Since checkpatch is saying this _might_ be better ... perhaps
> > > checkpatch could emit CHECK instead of WARNING for this?
>
> CHECKs aren't enabled by default except for a few
> directories and this warning is much more commonly
> correct than incorrect.
Ok, thanks.
> checkpatch will always have both false positives and
> false negatives. It's stupid, people generally aren't.
>
> Just ignore checkpatch bleats that aren't appropriate.
Got it, cheers Andy.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-06 20:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-06 4:19 checkpatch potential false positive Tobin C. Harding
2017-11-06 8:33 ` Andy Whitcroft
2017-11-06 15:29 ` Joe Perches
2017-11-06 20:54 ` Tobin C. Harding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox