* [PATCH] Staging: iio: Replace const char * with const char []
@ 2015-03-16 0:07 Cristina Opriceana
2015-03-16 9:11 ` [Outreachy kernel] " Daniel Baluta
0 siblings, 1 reply; 2+ messages in thread
From: Cristina Opriceana @ 2015-03-16 0:07 UTC (permalink / raw)
To: outreachy-kernel
Replace const char * with const char [] as the first one is represented
in memory as a pointer which points to a string and the second one only
as a single variable in which it copies the contents.
Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
---
This can be tested by generating assembly code for the two cases;
This platform also offers a simple view: http://assembly.ynh.io/.
drivers/staging/iio/Documentation/iio_utils.h | 2 +-
drivers/staging/iio/Documentation/lsiio.c | 4 ++--
drivers/staging/iio/iio_dummy_evgen.c | 2 +-
drivers/staging/iio/iio_simple_dummy.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index bd6982c..aa9570a 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -23,7 +23,7 @@
#define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
#define FORMAT_TYPE_FILE "%s_type"
-const char *iio_dir = "/sys/bus/iio/devices/";
+const char iio_dir[] = "/sys/bus/iio/devices/";
/**
* iioutils_break_up_name() - extract generic name from full channel name
diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c
index 98a0de0..50b0c70 100644
--- a/drivers/staging/iio/Documentation/lsiio.c
+++ b/drivers/staging/iio/Documentation/lsiio.c
@@ -26,8 +26,8 @@ static enum verbosity {
VERBLEVEL_SENSORS, /* 1 lists sensors */
} verblevel = VERBLEVEL_DEFAULT;
-const char *type_device = "iio:device";
-const char *type_trigger = "trigger";
+const char type_device[] = "iio:device";
+const char type_trigger[] = "trigger";
static inline int check_prefix(const char *str, const char *prefix)
diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c
index 59ad5a3..866e366 100644
--- a/drivers/staging/iio/iio_dummy_evgen.c
+++ b/drivers/staging/iio/iio_dummy_evgen.c
@@ -47,7 +47,7 @@ struct iio_dummy_eventgen {
/* We can only ever have one instance of this 'device' */
static struct iio_dummy_eventgen *iio_evgen;
-static const char *iio_evgen_name = "iio_dummy_evgen";
+static const char iio_evgen_name[] = "iio_dummy_evgen";
static void iio_dummy_event_irqmask(struct irq_data *d)
{
diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c
index 8341dce..4fe1073 100644
--- a/drivers/staging/iio/iio_simple_dummy.c
+++ b/drivers/staging/iio/iio_simple_dummy.c
@@ -36,7 +36,7 @@ module_param(instances, int, 0);
static struct iio_dev **iio_dummy_devs;
/* Fake a name for the part number, usually obtained from the id table */
-static const char *iio_dummy_part_number = "iio_dummy_part_no";
+static const char iio_dummy_part_number[] = "iio_dummy_part_no";
/**
* struct iio_dummy_accel_calibscale - realworld to register mapping
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [Outreachy kernel] [PATCH] Staging: iio: Replace const char * with const char []
2015-03-16 0:07 [PATCH] Staging: iio: Replace const char * with const char [] Cristina Opriceana
@ 2015-03-16 9:11 ` Daniel Baluta
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Baluta @ 2015-03-16 9:11 UTC (permalink / raw)
To: Cristina Opriceana; +Cc: outreachy-kernel
On Mon, Mar 16, 2015 at 2:07 AM, Cristina Opriceana
<cristina.opriceana@gmail.com> wrote:
> Replace const char * with const char [] as the first one is represented
> in memory as a pointer which points to a string and the second one only
> as a single variable in which it copies the contents.
>
> Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
> ---
> This can be tested by generating assembly code for the two cases;
> This platform also offers a simple view: http://assembly.ynh.io/.
>
> drivers/staging/iio/Documentation/iio_utils.h | 2 +-
> drivers/staging/iio/Documentation/lsiio.c | 4 ++--
> drivers/staging/iio/iio_dummy_evgen.c | 2 +-
> drivers/staging/iio/iio_simple_dummy.c | 2 +-
> 4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
> index bd6982c..aa9570a 100644
> --- a/drivers/staging/iio/Documentation/iio_utils.h
> +++ b/drivers/staging/iio/Documentation/iio_utils.h
> @@ -23,7 +23,7 @@
> #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
> #define FORMAT_TYPE_FILE "%s_type"
>
> -const char *iio_dir = "/sys/bus/iio/devices/";
> +const char iio_dir[] = "/sys/bus/iio/devices/";
>
> /**
> * iioutils_break_up_name() - extract generic name from full channel name
> diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c
> index 98a0de0..50b0c70 100644
> --- a/drivers/staging/iio/Documentation/lsiio.c
> +++ b/drivers/staging/iio/Documentation/lsiio.c
> @@ -26,8 +26,8 @@ static enum verbosity {
> VERBLEVEL_SENSORS, /* 1 lists sensors */
> } verblevel = VERBLEVEL_DEFAULT;
>
> -const char *type_device = "iio:device";
> -const char *type_trigger = "trigger";
> +const char type_device[] = "iio:device";
> +const char type_trigger[] = "trigger";
This will generate a conflict when merged with IIO tree, since parts
of Documentation/
(e.g lsiio.c iio_utils.h) were moved out of stating.
https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/commit/?h=testing&id=817020cfb3a2649064a1e14e083934234e2c208d
>
>
> static inline int check_prefix(const char *str, const char *prefix)
> diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c
> index 59ad5a3..866e366 100644
> --- a/drivers/staging/iio/iio_dummy_evgen.c
> +++ b/drivers/staging/iio/iio_dummy_evgen.c
> @@ -47,7 +47,7 @@ struct iio_dummy_eventgen {
>
> /* We can only ever have one instance of this 'device' */
> static struct iio_dummy_eventgen *iio_evgen;
> -static const char *iio_evgen_name = "iio_dummy_evgen";
> +static const char iio_evgen_name[] = "iio_dummy_evgen";
>
> static void iio_dummy_event_irqmask(struct irq_data *d)
> {
> diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c
> index 8341dce..4fe1073 100644
> --- a/drivers/staging/iio/iio_simple_dummy.c
> +++ b/drivers/staging/iio/iio_simple_dummy.c
> @@ -36,7 +36,7 @@ module_param(instances, int, 0);
> static struct iio_dev **iio_dummy_devs;
>
> /* Fake a name for the part number, usually obtained from the id table */
> -static const char *iio_dummy_part_number = "iio_dummy_part_no";
> +static const char iio_dummy_part_number[] = "iio_dummy_part_no";
>
> /**
> * struct iio_dummy_accel_calibscale - realworld to register mapping
I'm not sure I see the benefit of this patch.
Any other opinions?
Daniel.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-16 9:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-16 0:07 [PATCH] Staging: iio: Replace const char * with const char [] Cristina Opriceana
2015-03-16 9:11 ` [Outreachy kernel] " Daniel Baluta
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.