All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: unisys: Change char * array type as static const
@ 2015-02-23 22:12 aybuke ozdemir
  2015-02-23 22:19 ` [Outreachy kernel] " Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: aybuke ozdemir @ 2015-02-23 22:12 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: aybuke ozdemir

This patch fixes "char * array declaration might be better as static
const" checkpatch.pl warning in visorchipset_main.c
After this exchange that can be accessed pointer, without object
derived from the instance but just just read operation can be done in
pointer.

Signed-off-by: aybuke ozdemir <aybuke.147@gmail.com>
---
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index f606ee9..9f25c7f 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -1009,7 +1009,7 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
 
 	struct visorchipset_device_info *pDevInfo =
 		finddevice(&DevInfoList, busNo, devNo);
-	char *envp[] = {
+	static char const *envp[] = {
 		"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
 		NULL
 	};
@@ -1481,7 +1481,7 @@ int
 visorchipset_chipset_selftest(void)
 {
 	char env_selftest[20];
-	char *envp[] = { env_selftest, NULL };
+	static char const *envp[] = { env_selftest, NULL };
 
 	sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
 	kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
@@ -1637,7 +1637,7 @@ 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[] = {
+	static char const *envp[] = {
 		env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
 	};
 
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: unisys: Change char * array type as static const
  2015-02-23 22:12 [PATCH] Staging: unisys: Change char * array type as static const aybuke ozdemir
@ 2015-02-23 22:19 ` Arnd Bergmann
  2015-02-24 22:25   ` aybüke özdemir
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2015-02-23 22:19 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: aybuke ozdemir

On Tuesday 24 February 2015 00:12:45 aybuke ozdemir wrote:
> @@ -1481,7 +1481,7 @@ int
>  visorchipset_chipset_selftest(void)
>  {
>         char env_selftest[20];
> -       char *envp[] = { env_selftest, NULL };
> +       static char const *envp[] = { env_selftest, NULL };
>  
>         sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
>         kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,

Did you mean 'static const char *const envp[]'?

> @@ -1637,7 +1637,7 @@ 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[] = {
> +       static char const *envp[] = {
>                 env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
>         };

The actual strings are not const here, and the pointers point to objects
on the stack, so what does this change accomplish?

	Arnd


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: unisys: Change char * array type as static const
  2015-02-23 22:19 ` [Outreachy kernel] " Arnd Bergmann
@ 2015-02-24 22:25   ` aybüke özdemir
  0 siblings, 0 replies; 4+ messages in thread
From: aybüke özdemir @ 2015-02-24 22:25 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: outreachy-kernel

[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

Hi,

I've only changed the pointer, I made it const. I should use it like you
said(static const char *const). Because I can't do const string.

I'll make changes you said and send it again.

Regards

[-- Attachment #2: Type: text/html, Size: 1518 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: unisys: Change char * array type as static const
  2015-03-04 20:02 Yeliz Taneroglu
@ 2015-03-04 21:21 ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2015-03-04 21:21 UTC (permalink / raw)
  To: Yeliz Taneroglu; +Cc: outreachy-kernel

> @@ -1481,7 +1481,7 @@ int
>  visorchipset_chipset_selftest(void)
>  {
>  	char env_selftest[20];
> -	char *envp[] = { env_selftest, NULL };
> +	static const char *const envp[] = { env_selftest, NULL };

This appears to be quite incorrect.  env_selftest is an array with no
initialized information at this point.  Adding the const declarations
should make it impossible to put anything in the array.  It seems unlikely
that the compiler would allow this, unless the array is not used at all.
Furthermore, env_selftest is allocated on the stack, whereas a variable
that is declared as static is initialized only once, when the declaration
is first executed.  On subsequent calls to the function, envp will contain
a pointer to an address that now refers to something completely different.

julia



>  	sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
>  	kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
> @@ -1637,7 +1637,7 @@ 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[] = {
> +	static const char *const envp[] = {
>  		env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
>  	};
>
> --
> 1.8.3.2
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1425499377-11968-1-git-send-email-yeliztaneroglu%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-04 21:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-23 22:12 [PATCH] Staging: unisys: Change char * array type as static const aybuke ozdemir
2015-02-23 22:19 ` [Outreachy kernel] " Arnd Bergmann
2015-02-24 22:25   ` aybüke özdemir
2015-03-04 20:02 Yeliz Taneroglu
2015-03-04 21:21 ` [Outreachy kernel] " Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.