treewide-next: Use static const char arrays
Subsystems (25)
cover treewide-next: Use static const char arrays
Using static const char foo[] = "bar" can save some code and text space, so change the places where it's possible.
Also change the places that use
char foo[] = "barX";
...
foo[3] = value + '0';
where X is typically changed
char foo[sizeof("barX")];
...
sprintf(foo, "bar%c", value + '0');Joe Perches (25):
arch/mips: Use static const char arrays arch/powerpc: Use static const char arrays drivers/acpi: Use static const char arrays drivers/char: Use static const char arrays drivers/i2c: Use static const char arrays drivers/isdn: Use static const char arrays drivers/media: Use static const char arrays drivers/net/atl1c: Use static const char arrays drivers/net/atl1e: Use static const char arrays drivers/net/(intel): Use static const char arrays drivers/net/netxen: Use static const char arrays drivers/net/qlcnic: Use static const char arrays drivers/net/spider_net.c: Use static const char arrays drivers/net/vnxnet3: Use static const char arrays drivers/net/wireless/ipw2x00: Use static const char arrays drivers/s390/char: Use static const char arrays drivers/scsi: Use static const char arrays drivers/serial/suncore.c: Use static const char arrays drivers/staging: Use static const char arrays drivers/usb: Use static const char arrays drivers/video: Use static const char arrays net/dsa: Use static const char arrays net/sunrpc: Use static const char arrays
sound: Use static const char arrays tools/perf/util: Use static const char arrays
arch/mips/pnx8550/common/reset.c | 4 ++-- arch/powerpc/boot/addnote.c | 4 ++-- arch/powerpc/boot/cuboot-c2k.c | 4 ++-- arch/powerpc/kernel/irq.c | 2 +- drivers/acpi/sleep.c | 4 ++-- drivers/char/hvc_vio.c | 2 +- drivers/i2c/busses/i2c-stu300.c | 4 ++-- drivers/isdn/hysdn/hycapi.c | 2 +- drivers/isdn/mISDN/dsp_cmx.c | 2 +- drivers/media/video/zoran/zoran_device.c | 5 ++--- drivers/net/atl1c/atl1c.h | 4 ++-- drivers/net/atl1c/atl1c_main.c | 4 ++-- drivers/net/atl1e/atl1e.h | 4 ++-- drivers/net/atl1e/atl1e_main.c | 4 ++-- drivers/net/e1000/e1000.h | 2 +- drivers/net/e1000/e1000_main.c | 4 ++-- drivers/net/e1000e/e1000.h | 2 +- drivers/net/e1000e/netdev.c | 2 +- drivers/net/igb/igb.h | 4 ++-- drivers/net/igb/igb_main.c | 4 ++-- drivers/net/igbvf/igbvf.h | 2 +- drivers/net/igbvf/netdev.c | 2 +- drivers/net/ixgb/ixgb.h | 2 +- drivers/net/ixgb/ixgb_main.c | 2 +- drivers/net/ixgbe/ixgbe.h | 2 +- drivers/net/ixgbe/ixgbe_main.c | 4 ++-- drivers/net/ixgbevf/ixgbevf.h | 2 +- drivers/net/ixgbevf/ixgbevf_main.c | 2 +- drivers/net/netxen/netxen_nic.h | 2 +- drivers/net/netxen/netxen_nic_main.c | 2 +- drivers/net/qlcnic/qlcnic.h | 2 +- drivers/net/qlcnic/qlcnic_main.c | 2 +- drivers/net/spider_net.c | 2 +- drivers/net/vmxnet3/vmxnet3_drv.c | 2 +- drivers/net/vmxnet3/vmxnet3_int.h | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- drivers/net/wireless/ipw2x00/ipw2200.c | 2 +- drivers/net/wireless/ipw2x00/libipw_module.c | 2 +- drivers/s390/char/vmlogrdr.c | 4 ++-- drivers/scsi/bnx2i/bnx2i_hwi.c | 6 +++--- drivers/scsi/lpfc/lpfc_init.c | 2 +- drivers/scsi/megaraid/megaraid_mbox.c | 6 +++--- drivers/serial/suncore.c | 4 ++-- drivers/staging/brcm80211/util/bcmutils.c | 2 +- drivers/staging/comedi/drivers/comedi_bond.c | 2 +- drivers/staging/cxt1e1/ossiRelease.c | 2 +- drivers/staging/go7007/go7007-driver.c | 2 +- drivers/staging/msm/mdp.c | 2 +- .../staging/rtl8192e/ieee80211/ieee80211_module.c | 2 +- .../staging/rtl8192u/ieee80211/ieee80211_module.c | 2 +- drivers/staging/tidspbridge/rmgr/dbdcd.c | 6 +++--- drivers/usb/atm/ueagle-atm.c | 14 +++++--------- drivers/usb/otg/langwell_otg.c | 2 +- drivers/video/sh_mipi_dsi.c | 4 ++-- drivers/video/sis/sis_main.c | 10 +++++----- drivers/video/via/viafbdev.c | 2 +- net/dsa/dsa.c | 2 +- net/dsa/dsa_priv.h | 2 +- net/sunrpc/auth_gss/gss_krb5_mech.c | 2 +- sound/core/misc.c | 5 ++++- tools/perf/util/ui/setup.c | 3 ++- tools/perf/util/ui/util.c | 3 ++- 62 files changed, 98 insertions(+), 98 deletions(-)
Signature · 1 line
1.7.3.rc1
PATCH 1/25 arch/mips: Use static const char arrays
--- arch/mips/pnx8550/common/reset.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/pnx8550/common/reset.c +2 -2
@@ -27,8 +27,8 @@void pnx8550_machine_restart (char *command) { -char head[] ="************* Machine restart *************" ; -char foot[] ="*******************************************" ; +static const char head[] ="************* Machine restart *************" ; +static const char foot[] ="*******************************************" ;printk ("\n\n" );printk ("%s\n" , head);
Signature · 1 line
1.7.3.rc1
Ralf Baechle
NAKRe: [PATCH 01/25] arch/mips: Use static const char arrays
Quoted 5 lines · Joe Perches
arch/mips/pnx8550/common/reset.c +0
-0
arch/mips/pnx8550/common/reset.c line 34
Quoted 10 lines
arch/mips/pnx8550/common/reset.c +2
-2@@ -27,8 +27,8 @@void pnx8550_machine_restart (char *command) { -char head[] ="************* Machine restart *************" ; -char foot[] ="*******************************************" ; +static const char head[] ="************* Machine restart *************" ; +static const char foot[] ="*******************************************" ;printk ("\n\n" );printk ("%s\n" , head);
NAK.
The printks should have been taken out and shot. And while at it line use the space on the other side of the wall for pnx8550_machine_power_off.
Ralf
Re: [PATCH 01/25] arch/mips: Use static const char arrays
Quoted 14 lines · Ralf Baechle
Quoted 13 lines · Joe Perches
arch/mips/pnx8550/common/reset.c +2
-2@@ -27,8 +27,8 @@void pnx8550_machine_restart (char *command) { -char head[] ="************* Machine restart *************" ; -char foot[] ="*******************************************" ; +static const char head[] ="************* Machine restart *************" ; +static const char foot[] ="*******************************************" ;
Quoted 5 lines
arch/mips/pnx8550/common/reset.c line 34
Quoted 2 lines
arch/mips/pnx8550/common/reset.c +0
-0printk ("\n\n" );printk ("%s\n" , head);NAK.
The printks should have been taken out and shot. And while at it line use the space on the other side of the wall forpnx8550_machine_power_off.
Fix them up as you see fit Ralf.
I don't have the hardware and was simply moving stuff that should be const into const ro sections.
There are a lot of defects in that file, for instance the printks don't use KERN_<level>.
cheers, Joe
PATCH 2/25 arch/powerpc: Use static const char arrays
In reply to Joe Perches--- arch/powerpc/boot/addnote.c | 4 ++-- arch/powerpc/boot/cuboot-c2k.c | 4 ++-- arch/powerpc/kernel/irq.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/powerpc/boot/addnote.c +2 -2
@@ -20,7 +20,7 @@#include <string.h> /* CHRP note section */ -char arch[] ="PowerPC" ; +static const char arch[] ="PowerPC" ;#define N_DESCR 6unsigned int descr[N_DESCR ] = {
@@ -33,7 +33,7 @@ unsigned int descr[N_DESCR] = { };/* RPA note section */ -char rpaname[] ="IBM,RPA-Client-Config" ; +static const char rpaname[] ="IBM,RPA-Client-Config" ;/* * Note: setting ignore_my_client_config *should* mean that OF ignores
arch/powerpc/boot/cuboot-c2k.c +2 -2
@@ -62,9 +62,9 @@ static void c2k_bridge_setup(u32 mem_size)/* Get the cpu -> pci i/o & mem mappings from the device tree */ devp =NULL ;for (bus =0 ; ; bus++) { -char name[] ="pci " ; +char name[sizeof ("pciX" )]; - name[strlen (name)-1 ] = bus+'0' ; +sprintf (name,"pci%c" , bus +'0' ); devp =find_node_by_alias (name);if (devp ==NULL )
arch/powerpc/kernel/irq.c +1 -1
@@ -1143,7 +1143,7 @@ static int virq_debug_show(struct seq_file *m, void *private)unsigned long flags;struct irq_desc *desc;const char *p; -char none[] ="none" ; +static const char none[] ="none" ;int i; seq_printf(m, "%-5s %-7s %-15s %s\n", "virq", "hwirq",
Signature · 1 line
1.7.3.rc1
Re: [PATCH 02/25] arch/powerpc: Use static const char arrays
Hi Joe,
Quoted 7 lines · On Mon, 13 Sep 2010 12:47:40 -0700 Joe Perches <[email protected]> wrote:
Signed-off-by Joe Perches <[email protected]>--- arch/powerpc/boot/addnote.c | 4 ++-- arch/powerpc/boot/cuboot-c2k.c | 4 ++-- arch/powerpc/kernel/irq.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
I am also unsure that the transformation to cuboot-c2k.c adds anything. Other than that
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Re: [PATCH 02/25] arch/powerpc: Use static const char arrays
In reply to Joe PerchesBTW, Ben Herrenschmidt is the current PowerPC maintainer.
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
PATCH 3/25 drivers/acpi: Use static const char arrays
In reply to Joe Perches--- drivers/acpi/sleep.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/sleep.c +2 -2
@@ -567,7 +567,7 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p) {acpi_handle handle =DEVICE_ACPI_HANDLE (dev);struct acpi_device *adev; -char acpi_method[] ="_SxD" ; +char acpi_method[sizeof ("_SxD" )];unsigned long long d_min, d_max;if (!handle ||ACPI_FAILURE (acpi_bus_get_device (handle, &adev))) {
@@ -575,7 +575,7 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p)return -ENODEV ; } - acpi_method[2 ] ='0' + acpi_target_sleep_state; +sprintf (acpi_method,"_S%cD" ,'0' + acpi_target_sleep_state);/* * If the sleep state is S0, we will return D3, but if the device has * _S0W, we will use the value from _S0W
Signature · 1 line
1.7.3.rc1
PATCH 4/25 drivers/char: Use static const char arrays
In reply to Joe Perches--- drivers/char/hvc_vio.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/hvc_vio.c +1 -1
@@ -39,7 +39,7 @@#include "hvc_console.h" -char hvc_driver_name[] ="hvc_console" ; +static const char hvc_driver_name[] ="hvc_console" ;static struct vio_device_id hvc_driver_table[]__devinitdata = { {"serial" ,"hvterm1" },
Signature · 1 line
1.7.3.rc1
Re: [PATCH 04/25] drivers/char: Use static const char arrays
Hi Joe,
Quoted 2 lines · On Mon, 13 Sep 2010 12:47:42 -0700 Joe Perches <[email protected]> wrote:
Signed-off-by Joe Perches <[email protected]>
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
PATCH 5/25 drivers/i2c: Use static const char arrays
In reply to Joe Perches--- drivers/i2c/busses/i2c-stu300.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-stu300.c +2 -2
@@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev)struct resource *res;int bus_nr;int ret =0 ; -char clk_name[] ="I2C0" ; +char clk_name[sizeof ("I2Cx" )]; dev =kzalloc (sizeof (struct stu300_dev ),GFP_KERNEL );if (!dev) {
@@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) } bus_nr = pdev->id; - clk_name[3 ] += (char )bus_nr; +sprintf (clk_name,"I2C%c" ,'0' + bus_nr); dev->clk =clk_get (&pdev->dev, clk_name);if (IS_ERR (dev->clk)) { ret =PTR_ERR (dev->clk);
Signature · 1 line
1.7.3.rc1
Re: [PATCH 05/25] drivers/i2c: Use static const char arrays
Quoted 19 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- drivers/i2c/busses/i2c-stu300.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-stu300.c +1
-1@@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev)struct resource *res;int bus_nr;int ret =0 ; -char clk_name[] ="I2C0" ; +char clk_name[sizeof ("I2Cx" )]; dev =kzalloc (sizeof (struct stu300_dev ),GFP_KERNEL );if (!dev) {
drivers/i2c/busses/i2c-stu300.c stu300_probe(struct platform_device *pdev) · line 884
Quoted 5 lines
drivers/i2c/busses/i2c-stu300.c +1
-1@@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) } bus_nr = pdev->id; - clk_name[3 ] += (char )bus_nr; +sprintf (clk_name,"I2C%c" ,'0' + bus_nr);
If people would implement the clk API correctly (matching by struct device rather than giving every clock a name and trying to use the const char * as the sole matching token), stuff like this would not be necessary. The second argument to clk_get() is supposed to be a _consumer_ name (iow, something to determine which clock for the struct device you want) rather than a producer name.
Re: [PATCH 05/25] drivers/i2c: Use static const char arrays
In reply to Joe PerchesCommit message is somewhat inaccurate...
Quoted 19 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- drivers/i2c/busses/i2c-stu300.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-stu300.c +1
-1@@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev)struct resource *res;int bus_nr;int ret =0 ; -char clk_name[] ="I2C0" ; +char clk_name[sizeof ("I2Cx" )]; dev =kzalloc (sizeof (struct stu300_dev ),GFP_KERNEL );if (!dev) {
drivers/i2c/busses/i2c-stu300.c stu300_probe(struct platform_device *pdev) · line 884
Quoted 5 lines
drivers/i2c/busses/i2c-stu300.c +1
-1@@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) } bus_nr = pdev->id; - clk_name[3 ] += (char )bus_nr; +sprintf (clk_name,"I2C%c" ,'0' + bus_nr);
I'm guessing that there are never more than a couple of these. Why is this method a better bet than just putting %d?
Quoted 3 lines
drivers/i2c/busses/i2c-stu300.c +0
-0dev->clk =clk_get (&pdev->dev, clk_name);if (IS_ERR (dev->clk)) { ret =PTR_ERR (dev->clk);
Re: [PATCH 05/25] drivers/i2c: Use static const char arrays
Quoted 1 line · Jonathan Cameron
Commit message is somewhat inaccurate...
Yeah, sorry 'bout that.
That's what I get for using a script.
I did write an intro with more complete description.
Quoted 9 lines
drivers/i2c/busses/i2c-stu300.c stu300_probe(struct platform_device *pdev) · line 884
Quoted 7 lines
drivers/i2c/busses/i2c-stu300.c +1
-1@@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) } bus_nr = pdev->id; - clk_name[3 ] += (char )bus_nr; +sprintf (clk_name,"I2C%c" ,'0' + bus_nr);I'm guessing that there are never more than a couple of these. Why is this method a better bet than just putting %d?
It tries to standardize the style use and it avoids possible future checkpatch warnings of:
char foo[] = "bar"
char array could possibly be static const.
There was another use with "%1.1d" somewhere.
The end result is the same, so I don't really care much if this sort of change is applied or not. The possible checkpatch message could just be considered noise but Mike Frysinger seemed to prefer it, so I thought I could try to accommodate him.
cheers, Joe
Re: [PATCH 05/25] drivers/i2c: Use static const char arrays
In reply to Jonathan CameronHi,
Quoted 24 lines · Jonathan Cameron
Commit message is somewhat inaccurate...
Quoted 21 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- drivers/i2c/busses/i2c-stu300.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-stu300.c +1
-1@@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev)struct resource *res;int bus_nr;int ret =0 ; -char clk_name[] ="I2C0" ; +char clk_name[sizeof ("I2Cx" )]; dev =kzalloc (sizeof (struct stu300_dev ),GFP_KERNEL );if (!dev) {@@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) }
Quoted 6 lines
drivers/i2c/busses/i2c-stu300.c stu300_probe(struct platform_device *pdev) · line 884
Quoted 3 lines
drivers/i2c/busses/i2c-stu300.c +1
-1bus_nr = pdev->id; - clk_name[3 ] += (char )bus_nr; +sprintf (clk_name,"I2C%c" ,'0' + bus_nr);I'm guessing that there are never more than a couple of these. Why is this method a better bet than just putting %d?
'%c' will only ever produce one byte of output while '%d' may produce up to 11 bytes depending on the value of bus_nr thus overflowing the buffer.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
Re: [PATCH 05/25] drivers/i2c: Use static const char arrays
Quoted 33 lines · Lothar Wa?mann
Hi,
Quoted 24 lines · Jonathan Cameron
Commit message is somewhat inaccurate...
Quoted 21 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- drivers/i2c/busses/i2c-stu300.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-stu300.c +1
-1@@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev)struct resource *res;int bus_nr;int ret =0 ; -char clk_name[] ="I2C0" ; +char clk_name[sizeof ("I2Cx" )]; dev =kzalloc (sizeof (struct stu300_dev ),GFP_KERNEL );if (!dev) {@@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) }Quoted 6 lines
drivers/i2c/busses/i2c-stu300.c stu300_probe(struct platform_device *pdev) · line 884
Quoted 3 lines
drivers/i2c/busses/i2c-stu300.c +1
-1bus_nr = pdev->id; - clk_name[3 ] += (char )bus_nr; +sprintf (clk_name,"I2C%c" ,'0' + bus_nr);I'm guessing that there are never more than a couple of these. Why is this method a better bet than just putting %d?
Quoted 3 lines
'%c' will only ever produce one byte of output while '%d' may produce up to 11 bytes depending on the value of
bus_nrthus overflowing the buffer.
Then use an snprintf, or apply a check to ensure it isn't bigger than 9.
If you don't mind having clocks named i2c$ or something equally silly then I guess this is fine. To my mind, if that is possible this is a bug that should be fixed rather than avoided.
Re: [PATCH 05/25] drivers/i2c: Use static const char arrays
Quoted 37 lines · Jonathan Cameron
Quoted 33 lines · Lothar Wa?mann
Hi,
Quoted 24 lines · Jonathan Cameron
Commit message is somewhat inaccurate...
Quoted 21 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- drivers/i2c/busses/i2c-stu300.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-stu300.c +1
-1@@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev)struct resource *res;int bus_nr;int ret =0 ; -char clk_name[] ="I2C0" ; +char clk_name[sizeof ("I2Cx" )]; dev =kzalloc (sizeof (struct stu300_dev ),GFP_KERNEL );if (!dev) {@@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) }Quoted 6 lines
drivers/i2c/busses/i2c-stu300.c stu300_probe(struct platform_device *pdev) · line 884
Quoted 3 lines
drivers/i2c/busses/i2c-stu300.c +1
-1bus_nr = pdev->id; - clk_name[3 ] += (char )bus_nr; +sprintf (clk_name,"I2C%c" ,'0' + bus_nr);I'm guessing that there are never more than a couple of these. Why is this method a better bet than just putting %d?
Quoted 3 lines
'%c' will only ever produce one byte of output while '%d' may produce up to 11 bytes depending on the value of
bus_nrthus overflowing the buffer.
Quoted 6 lines
Then use an snprintf, or apply a check to ensure it isn't bigger than 9.
If you don't mind having clocks named i2c$ or something equally silly then I guess this is fine. To my mind, if that is possible this is a bug that should be fixed rather than avoided.
Even better, fix the implementation so that it conforms to the API spec rather than doing its own thing with the consumer connection ID argument and ignoring the struct device argument.
Re: [PATCH 05/25] drivers/i2c: Use static const char arrays
In reply to Joe PerchesQuoted 19 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- drivers/i2c/busses/i2c-stu300.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-stu300.c +1
-1@@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev)struct resource *res;int bus_nr;int ret =0 ; -char clk_name[] ="I2C0" ; +char clk_name[sizeof ("I2Cx" )]; dev =kzalloc (sizeof (struct stu300_dev ),GFP_KERNEL );if (!dev) {
drivers/i2c/busses/i2c-stu300.c stu300_probe(struct platform_device *pdev) · line 887
Quoted 8 lines
drivers/i2c/busses/i2c-stu300.c +1
-1@@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) } bus_nr = pdev->id; - clk_name[3 ] += (char )bus_nr; +sprintf (clk_name,"I2C%c" ,'0' + bus_nr); dev->clk =clk_get (&pdev->dev, clk_name);if (IS_ERR (dev->clk)) { ret =PTR_ERR (dev->clk);
personally, i'd prefer to see snprintf() used, to ensure that this sort of thing never goes wrong if people decde to change the string. It is a pitty there's no good way of temporarily allocating data an having it freed in C.
As such, apologies to Russell about the abuse of the clk_get() call, but let's not fix that just now.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
PATCH 6/25 drivers/isdn: Use static const char arrays
In reply to Joe Perches--- drivers/isdn/hysdn/hycapi.c | 2 +- drivers/isdn/mISDN/dsp_cmx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/isdn/hysdn/hycapi.c +1 -1
@@ -151,7 +151,7 @@ static void hycapi_register_internal(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp) { - char ExtFeatureDefaults[] = "49 /0/0/0/0,*/1,*/2,*/3,*/4,*/5,*/6,*/7,*/8,*/9,*"; + static const char ExtFeatureDefaults[] = "49 /0/0/0/0,*/1,*/2,*/3,*/4,*/5,*/6,*/7,*/8,*/9,*";hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);hysdn_card *card = cinfo->card;struct sk_buff *skb;
drivers/isdn/mISDN/dsp_cmx.c +1 -1
@@ -1155,7 +1155,7 @@ int delaycount;static void showdelay (struct dsp *dsp,int samples,int delay) { -char bar[] ="--------------------------------------------------|" ; +static const char bar[] ="--------------------------------------------------|" ;int sdelay; delaycount += samples;
Signature · 1 line
1.7.3.rc1
PATCH 7/25 drivers/media: Use static const char arrays
In reply to Joe Perches--- drivers/media/video/zoran/zoran_device.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/media/video/zoran/zoran_device.c +2 -3
@@ -1470,8 +1470,7 @@ zoran_irq (int irq, (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || zr->codec_mode == BUZ_MODE_MOTION_COMPRESS)) {if (zr36067_debug >1 && (!zr->frame_num || zr->JPEG_error)) { -char sc[] ="0000" ; -char sv[5 ]; +char sv[sizeof ("0000" )];int i; printk(KERN_INFO
@@ -1481,7 +1480,7 @@ zoran_irq (int irq, zr->jpg_settings.field_per_buff, zr->JPEG_missed); -strcpy (sv, sc); +strcpy (sv,"0000" );for (i =0 ; i <4 ; i++) {if (le32_to_cpu (zr->stat_com[i]) &1 ) sv[i] ='1' ;
Signature · 1 line
1.7.3.rc1
Re: [PATCH 07/25] drivers/media: Use static const char arrays
Em 13-09-2010 16:47, Joe Perches escreveu:
Quoted 20 lines
Signed-off-by Joe Perches <[email protected]>--- drivers/media/video/zoran/zoran_device.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)drivers/media/video/zoran/zoran_device.c +1
-2@@ -1470,8 +1470,7 @@ zoran_irq (int irq, (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || zr->codec_mode == BUZ_MODE_MOTION_COMPRESS)) {if (zr36067_debug >1 && (!zr->frame_num || zr->JPEG_error)) { -char sc[] ="0000" ; -char sv[5 ]; +char sv[sizeof ("0000" )];int i; printk(KERN_INFO
drivers/media/video/zoran/zoran_device.c zoran_irq (int irq, · line 1486
Quoted 8 lines
drivers/media/video/zoran/zoran_device.c +1
-1@@ -1481,7 +1480,7 @@ zoran_irq (int irq, zr->jpg_settings.field_per_buff, zr->JPEG_missed); -strcpy (sv, sc); +strcpy (sv,"0000" );for (i =0 ; i <4 ; i++) {if (le32_to_cpu (zr->stat_com[i]) &1 ) sv[i] ='1' ;
This looks ugly to me, as someone may change the string at strcpy and not change at sizeof. Could you please try to work on a better alternative?
The cleaner way seems to be to rewrite it as:
#define BUZ_MODE_STAT 4
char sv[BUZ_MODE_STAT + 1];
...
for (i = 0; i < BUZ_MODE_STAT; i++)
sv[i] = (le32_to_cpu(zr->stat_com[i]) & 1)? '1' : '0';
Cheers,
Mauro
PATCH 7/25 drivers/media/video/zoran: Don't use initialized char array
Just fill the array as necessary and terminate with 0
---
drivers/media/video/zoran/zoran_device.c +4 -8
@@ -1470,8 +1470,7 @@ zoran_irq (int irq, (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || zr->codec_mode == BUZ_MODE_MOTION_COMPRESS)) {if (zr36067_debug >1 && (!zr->frame_num || zr->JPEG_error)) { -char sc[] ="0000" ; -char sv[5 ]; +char sv[BUZ_NUM_STAT_COM +1 ];int i; printk(KERN_INFO
@@ -1481,12 +1480,9 @@ zoran_irq (int irq, zr->jpg_settings.field_per_buff, zr->JPEG_missed); -strcpy (sv, sc); -for (i =0 ; i <4 ; i++) { -if (le32_to_cpu (zr->stat_com[i]) &1 ) - sv[i] ='1' ; - } - sv[4 ] =0 ; +for (i =0 ; i <BUZ_NUM_STAT_COM ; i++) + sv[i] =le32_to_cpu (zr->stat_com[i]) &1 ?'1' :'0' ; + sv[BUZ_NUM_STAT_COM ] =0 ; printk(KERN_INFO "%s: stat_com=%s queue_state=%ld/%ld/%ld/%ld\n", ZR_DEVNAME(zr), sv,
PATCH 8/25 drivers/net/atl1c: Use static const char arrays
In reply to Joe Perches--- drivers/net/atl1c/atl1c.h | 4 ++-- drivers/net/atl1c/atl1c_main.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/atl1c/atl1c.h +2 -2
@@ -628,8 +628,8 @@ struct atl1c_adapter {#define AT_READ_REG_ARRAY (a, reg, offset) ( \ readl(((a)->hw_addr + reg) + ((offset) << 2))) -extern char atl1c_driver_name[]; -extern char atl1c_driver_version[]; +extern const char atl1c_driver_name[]; +extern const char atl1c_driver_version[];extern int atl1c_up (struct atl1c_adapter *adapter);extern void atl1c_down (struct atl1c_adapter *adapter);
drivers/net/atl1c/atl1c_main.c +2 -2
@@ -22,8 +22,8 @@#include "atl1c.h" #define ATL1C_DRV_VERSION "1.0.1.0-NAPI" -char atl1c_driver_name[] ="atl1c" ; -char atl1c_driver_version[] =ATL1C_DRV_VERSION ; +const char atl1c_driver_name[] ="atl1c" ; +const char atl1c_driver_version[] =ATL1C_DRV_VERSION ;#define PCI_DEVICE_ID_ATTANSIC_L2C 0x1062#define PCI_DEVICE_ID_ATTANSIC_L1C 0x1063#define PCI_DEVICE_ID_ATHEROS_L2C_B 0x2060/* AR8152 v1.1 Fast 10/100 */
Signature · 1 line
1.7.3.rc1
PATCH 9/25 drivers/net/atl1e: Use static const char arrays
In reply to Joe Perches--- drivers/net/atl1e/atl1e.h | 4 ++-- drivers/net/atl1e/atl1e_main.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/atl1e/atl1e.h +2 -2
@@ -498,8 +498,8 @@ struct atl1e_adapter {#define AT_READ_REG_ARRAY (a, reg, offset) ( \ readl(((a)->hw_addr + reg) + ((offset) << 2))) -extern char atl1e_driver_name[]; -extern char atl1e_driver_version[]; +extern const char atl1e_driver_name[]; +extern const char atl1e_driver_version[];extern void atl1e_check_options (struct atl1e_adapter *adapter);extern int atl1e_up (struct atl1e_adapter *adapter);
drivers/net/atl1e/atl1e_main.c +2 -2
@@ -23,8 +23,8 @@#define DRV_VERSION "1.0.0.7-NAPI" -char atl1e_driver_name[] ="ATL1E" ; -char atl1e_driver_version[] =DRV_VERSION ; +const char atl1e_driver_name[] ="ATL1E" ; +const char atl1e_driver_version[] =DRV_VERSION ;#define PCI_DEVICE_ID_ATTANSIC_L1E 0x1026/* * atl1e_pci_tbl - PCI Device ID Table
Signature · 1 line
1.7.3.rc1
PATCH 10/25 drivers/net/(intel): Use static const char arrays
In reply to Joe Perches--- drivers/net/e1000/e1000.h | 2 +- drivers/net/e1000/e1000_main.c | 4 ++-- drivers/net/e1000e/e1000.h | 2 +- drivers/net/e1000e/netdev.c | 2 +- drivers/net/igb/igb.h | 4 ++-- drivers/net/igb/igb_main.c | 4 ++-- drivers/net/igbvf/igbvf.h | 2 +- drivers/net/igbvf/netdev.c | 2 +- drivers/net/ixgb/ixgb.h | 2 +- drivers/net/ixgb/ixgb_main.c | 2 +- drivers/net/ixgbe/ixgbe.h | 2 +- drivers/net/ixgbe/ixgbe_main.c | 4 ++-- drivers/net/ixgbevf/ixgbevf.h | 2 +- drivers/net/ixgbevf/ixgbevf_main.c | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-)
drivers/net/e1000/e1000.h +1 -1
@@ -339,7 +339,7 @@ extern struct net_device *e1000_get_hw_dev(struct e1000_hw *hw); #define e_dev_err(format, arg...) \ dev_err(&adapter->pdev->dev, format, ## arg) -extern char e1000_driver_name[]; +extern const char e1000_driver_name[];extern const char e1000_driver_version[];extern int e1000_up (struct e1000_adapter *adapter);
drivers/net/e1000/e1000_main.c +2 -2
@@ -29,8 +29,8 @@#include "e1000.h" #include <net/ip6_checksum.h> -char e1000_driver_name[] ="e1000" ; -static char e1000_driver_string[] ="Intel(R) PRO/1000 Network Driver" ; +const char e1000_driver_name[] ="e1000" ; +static const char e1000_driver_string[] ="Intel(R) PRO/1000 Network Driver" ;#define DRV_VERSION "7.3.21-k6-NAPI"const char e1000_driver_version[] =DRV_VERSION ;static const char e1000_copyright[] ="Copyright (c) 1999-2006 Intel Corporation." ;
drivers/net/e1000e/e1000.h +1 -1
@@ -446,7 +446,7 @@ enum latency_range { latency_invalid = 255 }; -extern char e1000e_driver_name[]; +extern const char e1000e_driver_name[];extern const char e1000e_driver_version[];extern void e1000e_check_options (struct e1000_adapter *adapter);
drivers/net/e1000e/netdev.c +1 -1
@@ -55,7 +55,7 @@#define DRV_EXTRAVERSION "-k2"#define DRV_VERSION "1.2.7" DRV_EXTRAVERSION -char e1000e_driver_name[] ="e1000e" ; +const char e1000e_driver_name[] ="e1000e" ;const char e1000e_driver_version[] =DRV_VERSION ;static const struct e1000_info *e1000_info_tbl[] = {
drivers/net/igb/igb.h +2 -2
@@ -337,8 +337,8 @@ enum igb_boards { board_82575, }; -extern char igb_driver_name[]; -extern char igb_driver_version[]; +extern const char igb_driver_name[]; +extern const char igb_driver_version[];extern int igb_up (struct igb_adapter *);extern void igb_down (struct igb_adapter *);
drivers/net/igb/igb_main.c +2 -2
@@ -51,8 +51,8 @@#include "igb.h" #define DRV_VERSION "2.1.0-k2" -char igb_driver_name[] ="igb" ; -char igb_driver_version[] =DRV_VERSION ; +const char igb_driver_name[] ="igb" ; +const char igb_driver_version[] =DRV_VERSION ;static const char igb_driver_string[] ="Intel(R) Gigabit Ethernet Network Driver" ;static const char igb_copyright[] ="Copyright (c) 2007-2009 Intel Corporation." ;
drivers/net/igbvf/igbvf.h +1 -1
@@ -309,7 +309,7 @@ enum latency_range { latency_invalid = 255 }; -extern char igbvf_driver_name[]; +extern const char igbvf_driver_name[];extern const char igbvf_driver_version[];extern void igbvf_check_options (struct igbvf_adapter *);
drivers/net/igbvf/netdev.c +1 -1
@@ -46,7 +46,7 @@#include "igbvf.h" #define DRV_VERSION "1.0.0-k0" -char igbvf_driver_name[] ="igbvf" ; +const char igbvf_driver_name[] ="igbvf" ;const char igbvf_driver_version[] =DRV_VERSION ;static struct pm_qos_request_list igbvf_driver_pm_qos_req; static const char igbvf_driver_string[] =
drivers/net/ixgb/ixgb.h +1 -1
@@ -204,7 +204,7 @@ enum ixgb_state_t {/* Exported from other modules */ extern void ixgb_check_options (struct ixgb_adapter *adapter);extern void ixgb_set_ethtool_ops (struct net_device *netdev); -extern char ixgb_driver_name[]; +extern const char ixgb_driver_name[];extern const char ixgb_driver_version[];extern int ixgb_up (struct ixgb_adapter *adapter);
drivers/net/ixgb/ixgb_main.c +1 -1
@@ -30,7 +30,7 @@#include "ixgb.h" -char ixgb_driver_name[] ="ixgb" ; +const char ixgb_driver_name[] ="ixgb" ;static char ixgb_driver_string[] ="Intel(R) PRO/10GbE Network Driver" ;#define DRIVERNAPI "-NAPI"
drivers/net/ixgbe/ixgbe.h +1 -1
@@ -441,7 +441,7 @@ extern int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config *src_dcb_cfg, int tc_max);#endif -extern char ixgbe_driver_name[]; +extern const char ixgbe_driver_name[];extern const char ixgbe_driver_version[];extern int ixgbe_up (struct ixgbe_adapter *adapter);
drivers/net/ixgbe/ixgbe_main.c +2 -2
@@ -48,8 +48,8 @@#include "ixgbe_dcb_82599.h" #include "ixgbe_sriov.h" -char ixgbe_driver_name[] ="ixgbe" ; -static const char ixgbe_driver_string[] = +const char ixgbe_driver_name[] ="ixgbe" ; +const char ixgbe_driver_string[] ="Intel(R) 10 Gigabit PCI Express Network Driver" ;#define DRV_VERSION "2.0.84-k2"
drivers/net/ixgbevf/ixgbevf.h +1 -1
@@ -282,7 +282,7 @@ extern struct ixgbevf_info ixgbevf_vf_info;extern struct ixgbe_mac_operations ixgbevf_mbx_ops;/* needed by ethtool.c */ -extern char ixgbevf_driver_name[]; +extern const char ixgbevf_driver_name[];extern const char ixgbevf_driver_version[];extern int ixgbevf_up (struct ixgbevf_adapter *adapter);
drivers/net/ixgbevf/ixgbevf_main.c +1 -1
@@ -47,7 +47,7 @@#include "ixgbevf.h" -char ixgbevf_driver_name[] ="ixgbevf" ; +const char ixgbevf_driver_name[] ="ixgbevf" ;static const char ixgbevf_driver_string[] ="Intel(R) 82599 Virtual Function" ;
Signature · 13 lines
1.7.3.rc1 ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ E1000-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/e1000-devel To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
PATCH 11/25 drivers/net/netxen: Use static const char arrays
In reply to Joe Perches--- drivers/net/netxen/netxen_nic.h | 2 +- drivers/net/netxen/netxen_nic_main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/netxen/netxen_nic.h +1 -1
@@ -525,7 +525,7 @@ struct uni_data_desc{#define NX_UNIFIED_ROMIMAGE_NAME "phanfw.bin"#define NX_FLASH_ROMIMAGE_NAME "flash" -extern char netxen_nic_driver_name[]; +extern const char netxen_nic_driver_name[];/* Number of status descriptors to handle per interrupt */ #define MAX_STATUS_HANDLE (64)
drivers/net/netxen/netxen_nic_main.c +1 -1
@@ -46,7 +46,7 @@ MODULE_FIRMWARE(NX_P3_CT_ROMIMAGE_NAME);MODULE_FIRMWARE (NX_P3_MN_ROMIMAGE_NAME );MODULE_FIRMWARE (NX_UNIFIED_ROMIMAGE_NAME ); -char netxen_nic_driver_name[] ="netxen_nic" ; +const char netxen_nic_driver_name[] ="netxen_nic" ;static char netxen_nic_driver_string[] ="QLogic/NetXen Network Driver v" NETXEN_NIC_LINUX_VERSIONID ;
Signature · 1 line
1.7.3.rc1
PATCH 12/25 drivers/net/qlcnic: Use static const char arrays
In reply to Joe Perches--- drivers/net/qlcnic/qlcnic.h | 2 +- drivers/net/qlcnic/qlcnic_main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/qlcnic/qlcnic.h +1 -1
@@ -345,7 +345,7 @@ struct uni_data_desc{#define QLCNIC_UNIFIED_ROMIMAGE_NAME "phanfw.bin"#define QLCNIC_FLASH_ROMIMAGE_NAME "flash" -extern char qlcnic_driver_name[]; +extern const char qlcnic_driver_name[];/* Number of status descriptors to handle per interrupt */ #define MAX_STATUS_HANDLE (64)
drivers/net/qlcnic/qlcnic_main.c +1 -1
@@ -41,7 +41,7 @@ MODULE_LICENSE("GPL");MODULE_VERSION (QLCNIC_LINUX_VERSIONID );MODULE_FIRMWARE (QLCNIC_UNIFIED_ROMIMAGE_NAME ); -char qlcnic_driver_name[] ="qlcnic" ; +const char qlcnic_driver_name[] ="qlcnic" ;static const char qlcnic_driver_string[] ="QLogic 1/10 GbE " "Converged/Intelligent Ethernet Driver v" QLCNIC_LINUX_VERSIONID ;
Signature · 1 line
1.7.3.rc1
PATCH 13/25 drivers/net/spider_net.c: Use static const char arrays
In reply to Joe Perches--- drivers/net/spider_net.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/spider_net.c +1 -1
@@ -70,7 +70,7 @@ MODULE_PARM_DESC(rx_descriptors, "number of descriptors used " \MODULE_PARM_DESC (tx_descriptors,"number of descriptors used " \"in tx chain" ); -char spider_net_driver_name[] ="spidernet" ; +const char spider_net_driver_name[] ="spidernet" ;static DEFINE_PCI_DEVICE_TABLE (spider_net_pci_tbl) = { {PCI_VENDOR_ID_TOSHIBA_2 ,PCI_DEVICE_ID_TOSHIBA_SPIDER_NET ,
Signature · 1 line
1.7.3.rc1
PATCH 14/25 drivers/net/vnxnet3: Use static const char arrays
In reply to Joe Perches--- drivers/net/vmxnet3/vmxnet3_drv.c | 2 +- drivers/net/vmxnet3/vmxnet3_int.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/vmxnet3/vmxnet3_drv.c +1 -1
@@ -28,7 +28,7 @@#include "vmxnet3_int.h" -char vmxnet3_driver_name[] ="vmxnet3" ; +const char vmxnet3_driver_name[] ="vmxnet3" ;#define VMXNET3_DRIVER_DESC "VMware vmxnet3 virtual NIC driver"/*
drivers/net/vmxnet3/vmxnet3_int.h +1 -1
@@ -384,5 +384,5 @@ vmxnet3_create_queues(struct vmxnet3_adapter *adapter,extern void vmxnet3_set_ethtool_ops (struct net_device *netdev);extern struct net_device_stats *vmxnet3_get_stats (struct net_device *netdev); -extern char vmxnet3_driver_name[]; +extern const char vmxnet3_driver_name[];#endif
Signature · 1 line
1.7.3.rc1
RE: [Pv-drivers] [PATCH 14/25] drivers/net/vnxnet3: Use static const char arrays
Thanks.
Quoted 50 lines
-----Original Message-----
From: [email protected] [mailto:pv-drivers- [email protected]] On Behalf Of Joe Perches
Sent: Monday, September 13, 2010 12:48 PM
To: [email protected]
Cc: VMware, Inc.; [email protected]
Subject: [Pv-drivers] [PATCH 14/25]drivers/net/vnxnet3: Use static const char arraysSigned-off-by Joe Perches <[email protected]>--- drivers/net/vmxnet3/vmxnet3_drv.c | 2 +- drivers/net/vmxnet3/vmxnet3_int.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/net/vmxnet3/vmxnet3_drv.c +1
-1@@ -28,7 +28,7 @@#include "vmxnet3_int.h" -char vmxnet3_driver_name[] ="vmxnet3" ; +const char vmxnet3_driver_name[] ="vmxnet3" ;#define VMXNET3_DRIVER_DESC "VMware vmxnet3 virtual NIC driver"/* drivers/net/vmxnet3/vmxnet3_int.h +1
-2@@ -384,5 +384,5 @@ vmxnet3_create_queues(struct vmxnet3_adapter *adapter, extern void vmxnet3_set_ethtool_ops(struct net_device *netdev);extern struct net_device_stats *vmxnet3_get_stats (struct net_device *netdev); -extern char vmxnet3_driver_name[]; +extern const char vmxnet3_driver_name[];#endif --1.7.3.rc1
_______________________________________________
Pv-drivers mailing list
[email protected]
http://mailman2.vmware.com/mailman/listinfo/pv-drivers
RE: [PATCH 14/25] drivers/net/vnxnet3: Use static const char arrays
In reply to Joe PerchesThanks Joe.
Quoted 44 lines
-----Original Message-----
From: Joe Perches [mailto:[email protected]]
Sent: Monday, September 13, 2010 12:48 PM
To: [email protected]
Cc: Shreyas Bhatewara; VMware, Inc.; [email protected]
Subject: [PATCH 14/25]drivers/net/vnxnet3: Use static const char arraysSigned-off-by Joe Perches <[email protected]>--- drivers/net/vmxnet3/vmxnet3_drv.c | 2 +- drivers/net/vmxnet3/vmxnet3_int.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/net/vmxnet3/vmxnet3_drv.c +1
-1@@ -28,7 +28,7 @@#include "vmxnet3_int.h" -char vmxnet3_driver_name[] ="vmxnet3" ; +const char vmxnet3_driver_name[] ="vmxnet3" ;#define VMXNET3_DRIVER_DESC "VMware vmxnet3 virtual NIC driver"/* drivers/net/vmxnet3/vmxnet3_int.h +1
-2@@ -384,5 +384,5 @@ vmxnet3_create_queues(struct vmxnet3_adapter *adapter, extern void vmxnet3_set_ethtool_ops(struct net_device *netdev);extern struct net_device_stats *vmxnet3_get_stats (struct net_device *netdev); -extern char vmxnet3_driver_name[]; +extern const char vmxnet3_driver_name[];#endif --1.7.3.rc1
PATCH 15/25 drivers/net/wireless/ipw2x00: Use static const char arrays
In reply to Joe Perches--- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- drivers/net/wireless/ipw2x00/ipw2200.c | 2 +- drivers/net/wireless/ipw2x00/libipw_module.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ipw2x00/ipw2100.c +1 -1
@@ -4261,7 +4261,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, {struct ipw2100_priv *priv =dev_get_drvdata (d);struct net_device *dev = priv->net_dev; -char buffer[] ="00000000" ; +char buffer[sizeof ("00000000" )];unsigned long len = (sizeof (buffer) -1 ) > count ? count :sizeof (buffer) -1 ;unsigned long val;
drivers/net/wireless/ipw2x00/ipw2200.c +1 -1
@@ -1486,7 +1486,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, {struct ipw_priv *priv =dev_get_drvdata (d);struct net_device *dev = priv->net_dev; -char buffer[] ="00000000" ; +char buffer[sizeof ("00000000" )];unsigned long len = (sizeof (buffer) -1 ) > count ? count :sizeof (buffer) -1 ;unsigned long val;
drivers/net/wireless/ipw2x00/libipw_module.c +1 -1
@@ -261,7 +261,7 @@ static int debug_level_proc_open(struct inode *inode, struct file *file)static ssize_t debug_level_proc_write (struct file *file,const char __user *buffer,size_t count,loff_t *pos) { -char buf[] ="0x00000000\n" ; +char buf[sizeof ("0x00000000\n" )];size_t len =min (sizeof (buf) -1 , count);unsigned long val;
Signature · 1 line
1.7.3.rc1
Re: [PATCH 15/25] drivers/net/wireless/ipw2x00: Use static const char arrays
Quoted 12 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- drivers/net/wireless/ipw2x00/ipw2200.c | 2 +- drivers/net/wireless/ipw2x00/libipw_module.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/net/wireless/ipw2x00/ipw2100.c +0
-0
drivers/net/wireless/ipw2x00/ipw2100.c static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, · line 4267
Quoted 8 lines
drivers/net/wireless/ipw2x00/ipw2100.c +1
-1@@ -4261,7 +4261,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, {struct ipw2100_priv *priv =dev_get_drvdata (d);struct net_device *dev = priv->net_dev; -char buffer[] ="00000000" ; +char buffer[sizeof ("00000000" )];unsigned long len = (sizeof (buffer) -1 ) > count ? count :sizeof (buffer) -1 ;unsigned long val;
Had to look twice, since you replaced an initialization with a declaration. But in all these cases the initial value was already being overwritten before use anyway.
Quoted 30 lines
drivers/net/wireless/ipw2x00/ipw2200.c +1
-1@@ -1486,7 +1486,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, {struct ipw_priv *priv =dev_get_drvdata (d);struct net_device *dev = priv->net_dev; -char buffer[] ="00000000" ; +char buffer[sizeof ("00000000" )];unsigned long len = (sizeof (buffer) -1 ) > count ? count :sizeof (buffer) -1 ;unsigned long val;drivers/net/wireless/ipw2x00/libipw_module.c +1
-1@@ -261,7 +261,7 @@ static int debug_level_proc_open(struct inode *inode, struct file *file)static ssize_t debug_level_proc_write (struct file *file,const char __user *buffer,size_t count,loff_t *pos) { -char buf[] ="0x00000000\n" ; +char buf[sizeof ("0x00000000\n" )];size_t len =min (sizeof (buf) -1 , count);unsigned long val;Signature · 1 line
1.7.3.rc1
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
PATCH 16/25 drivers/s390/char: Use static const char arrays
In reply to Joe Perches--- drivers/s390/char/vmlogrdr.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/s390/char/vmlogrdr.c +2 -2
@@ -214,7 +214,7 @@ static void vmlogrdr_iucv_message_pending(struct iucv_path *path,static int vmlogrdr_get_recording_class_AB (void ) { -char cp_command[]="QUERY COMMAND RECORDING " ; +static const char cp_command[] ="QUERY COMMAND RECORDING " ;char cp_response[80 ];char *tail;int len,i;
@@ -637,7 +637,7 @@ static ssize_t vmlogrdr_recording_status_show(struct device_driver *driver, char *buf) { -char cp_command[] ="QUERY RECORDING " ; +static const char cp_command[] ="QUERY RECORDING " ;int len;cpcmd (cp_command, buf,4096 ,NULL );
Signature · 1 line
1.7.3.rc1
PATCH 17/25 drivers/scsi: Use static const char arrays
In reply to Joe Perches--- drivers/scsi/bnx2i/bnx2i_hwi.c | 6 +++--- drivers/scsi/lpfc/lpfc_init.c | 2 +- drivers/scsi/megaraid/megaraid_mbox.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/scsi/bnx2i/bnx2i_hwi.c +3 -3
@@ -1919,10 +1919,10 @@ static void bnx2i_process_iscsi_error(struct bnx2i_hba *hba, {struct bnx2i_conn *bnx2i_conn;u32 iscsi_cid; -char warn_notice[] ="iscsi_warning" ; -char error_notice[] ="iscsi_error" ; +static const char warn_notice[] ="iscsi_warning" ; +static const char error_notice[] ="iscsi_error" ;char additional_notice[64 ]; -char *message; +const char *message;int need_recovery;u64 err_mask64;
drivers/scsi/lpfc/lpfc_init.c +1 -1
@@ -281,7 +281,7 @@ lpfc_dump_wakeup_param_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)uint32_t prog_id_word;char dist =' ' ;/* character array used for decoding dist type. */ -char dist_char[] ="nabx" ; +static const char dist_char[] ="nabx" ;if (pmboxq->u.mb.mbxStatus !=MBX_SUCCESS ) {mempool_free (pmboxq, phba->mbox_mem_pool);
drivers/scsi/megaraid/megaraid_mbox.c +3 -3
@@ -1536,9 +1536,9 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)mbox64_t *mbox64;mbox_t *mbox;scb_t *scb; -char skip[] ="skipping" ; -char scan[] ="scanning" ; -char *ss; +static const char skip[] ="skipping" ; +static const char scan[] ="scanning" ; +const char *ss;/*
Signature · 1 line
1.7.3.rc1
PATCH 18/25 drivers/serial/suncore.c: Use static const char arrays
In reply to Joe Perches--- drivers/serial/suncore.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/serial/suncore.c +2 -2
@@ -84,8 +84,8 @@ EXPORT_SYMBOL(sunserial_console_match);void sunserial_console_termios (struct console *con,struct device_node *uart_dp) { +char mode_prop[sizeof ("ttyX-mode" )];const char *mode, *s; -char mode_prop[] ="ttyX-mode" ;int baud, bits, stop, cflag;char parity;
@@ -106,7 +106,7 @@ void sunserial_console_termios(struct console *con, struct device_node *uart_dp)if (of_console_options) c = *of_console_options; - mode_prop[3 ] = c; +sprintf (mode_prop,"tty%c-mode" , c); dp =of_find_node_by_path ("/options" ); mode =of_get_property (dp, mode_prop,NULL );
Signature · 1 line
1.7.3.rc1
Re: [PATCH 18/25] drivers/serial/suncore.c: Use static const char arrays
Quoted 20 lines · On Mon, 13 Sep 2010 12:47:56 -0700 Joe Perches <[email protected]> wrote:
Signed-off-by Joe Perches <[email protected]>--- drivers/serial/suncore.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/serial/suncore.c +1
-1@@ -84,8 +84,8 @@ EXPORT_SYMBOL(sunserial_console_match);void sunserial_console_termios (struct console *con,struct device_node *uart_dp) { +char mode_prop[sizeof ("ttyX-mode" )];const char *mode, *s; -char mode_prop[] ="ttyX-mode" ;int baud, bits, stop, cflag;char parity;
drivers/serial/suncore.c void sunserial_console_termios(struct console *con, struct device_node *uart_dp) · line 109
Quoted 5 lines
drivers/serial/suncore.c +1
-1@@ -106,7 +106,7 @@ void sunserial_console_termios(struct console *con, struct device_node *uart_dp)if (of_console_options) c = *of_console_options; - mode_prop[3 ] = c; +sprintf (mode_prop,"tty%c-mode" , c);
Whats the point of all this. It's trivial code being replaced by something complicated, harder to understand and much slower ?
Re: [PATCH 18/25] drivers/serial/suncore.c: Use static const char arrays
Quoted 11 lines · Alan Cox
drivers/serial/suncore.c void sunserial_console_termios(struct console *con, struct device_node *uart_dp) · line 109
Quoted 7 lines · On Mon, 13 Sep 2010 12:47:56 -0700 Joe Perches <[email protected]> wrote:
drivers/serial/suncore.c +1
-1@@ -106,7 +106,7 @@ void sunserial_console_termios(struct console *con, struct device_node *uart_dp)if (of_console_options) c = *of_console_options; - mode_prop[3 ] = c; +sprintf (mode_prop,"tty%c-mode" , c);Whats the point of all this. It's trivial code being replaced by something complicated, harder to understand and much slower ?
There are many cases of char foo[] = "bar" that should be actually be [static] const char foo[] etc. The patch set was done to change those cases.
This case isn't actually any sort of saving.
As I just wrote in 5/25 to Jonathan Cameron:
It tries to standardize the style use and it avoids possible future checkpatch warnings of:
char foo[] = "bar"
char array could possibly be static const.
There was another use with "%1.1d" somewhere.
The end result is the same, so I don't really care much if this sort of change is applied or not. The possible checkpatch message could just be considered noise but Mike Frysinger seemed to prefer it, so I thought I could try to accommodate him.
cheers, Joe
Re: [PATCH 18/25] drivers/serial/suncore.c: Use static const char arrays
Quoted 4 lines · Joe Perches
It tries to standardize the style use and it avoids possible future checkpatch warnings of:
char foo[] = "bar"char array could possibly be static const.
Whoa, back up a second here. I've seen patches to avoid questionable checkpatch warnings before, but I think this is the first time I've seen a patch to avoid *hypothetical checkpatch warnings that don't even exist*!
Signature · 1 line
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
Re: [PATCH 18/25] drivers/serial/suncore.c: Use static const char arrays
Quoted 9 lines · Nick Bowler
Quoted 4 lines · Joe Perches
It tries to standardize the style use and it avoids possible future checkpatch warnings of:
char foo[] = "bar"char array could possibly be static const.
Whoa, back up a second here. I've seen patches to avoid questionable checkpatch warnings before, but I think this is the first time I've seen a patch to avoid *hypothetical checkpatch warnings that don't even exist*!
Pretty cool huh? cheers, Joe
PATCH 19/25 drivers/staging: Use static const char arrays
In reply to Joe Perches--- drivers/staging/brcm80211/util/bcmutils.c | 2 +- drivers/staging/comedi/drivers/comedi_bond.c | 2 +- drivers/staging/cxt1e1/ossiRelease.c | 2 +- drivers/staging/go7007/go7007-driver.c | 2 +- drivers/staging/msm/mdp.c | 2 +- .../staging/rtl8192e/ieee80211/ieee80211_module.c | 2 +- .../staging/rtl8192u/ieee80211/ieee80211_module.c | 2 +- drivers/staging/tidspbridge/rmgr/dbdcd.c | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-)
drivers/staging/brcm80211/util/bcmutils.c +1 -1
@@ -905,7 +905,7 @@ static int findmatch(char *string, char *name)*/ uint getgpiopin (char *vars,char *pin_name,uint def_pin) { -char name[] ="gpioXXXX" ; +char name[sizeof ("gpioXXXX" )];char *val;uint pin;
drivers/staging/comedi/drivers/comedi_bond.c +1 -1
@@ -374,7 +374,7 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)/* Loop through all comedi devices specified on the command-line, building our device list */ for (i =0 ; i <COMEDI_NDEVCONFOPTS && (!i || it->options[i]); ++i) { -char file[] ="/dev/comediXXXXXX" ; +char file[sizeof ("/dev/comediXXXXXX" )];int minor = it->options[i];struct comedi_device *d;int sdev =-1 , nchans, tmp;
drivers/staging/cxt1e1/ossiRelease.c +1 -1
@@ -34,6 +34,6 @@*/ -char pmcc4_OSSI_release[] ="$Release: PMCC4_3_1B, Copyright (c) 2008 One Stop Systems$" ; +static const char pmcc4_OSSI_release[] ="$Release: PMCC4_3_1B, Copyright (c) 2008 One Stop Systems$" ;/*** End-of-File ***/
drivers/staging/go7007/go7007-driver.c +1 -1
@@ -92,7 +92,7 @@ EXPORT_SYMBOL(go7007_read_addr);static int go7007_load_encoder (struct go7007 *go) {const struct firmware *fw_entry; -char fw_name[] ="go7007fw.bin" ; +static const char fw_name[] ="go7007fw.bin" ;void *bounce;int fw_len, rv =0 ;u16 intr_val, intr_data;
drivers/staging/msm/mdp.c +1 -1
@@ -704,7 +704,7 @@ static void mdp_drv_init(void)#ifdef MSM_FB_ENABLE_DBGFS {struct dentry *root; -char sub_name[] ="mdp" ; +static const char sub_name[] ="mdp" ; root =msm_fb_get_debugfs_root ();if (root !=NULL ) {
drivers/staging/rtl8192e/ieee80211/ieee80211_module.c +1 -1
@@ -253,7 +253,7 @@ static int show_debug_level(char *page, char **start, off_t offset,static int store_debug_level (struct file *file,const char *buffer,unsigned long count,void *data) { -char buf[] ="0x00000000" ; +char buf[sizeof ("0x00000000" )];unsigned long len =min (sizeof (buf) -1 , (u32 )count);char *p = (char *)buf;unsigned long val;
drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +1 -1
@@ -256,7 +256,7 @@ static int show_debug_level(char *page, char **start, off_t offset,static int store_debug_level (struct file *file,const char *buffer,unsigned long count,void *data) { -char buf[] ="0x00000000" ; +char buf[sizeof ("0x00000000" )]; unsigned long len = min_t(unsigned long, sizeof(buf) - 1, count);char *p = (char *)buf;unsigned long val;
drivers/staging/tidspbridge/rmgr/dbdcd.c +3 -3
@@ -548,7 +548,7 @@ int dcd_get_objects(struct dcd_manager *hdcd_mgr,struct cod_libraryobj *lib =NULL ;u32 ul_addr =0 ;/* Used by cod_get_section */ u32 ul_len =0 ;/* Used by cod_get_section */ -char seps[] =":, " ; +static const char seps[] =":, " ;char *token =NULL ;struct dsp_uuid dsp_uuid_obj;s32 object_type;
@@ -1050,7 +1050,7 @@ static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size, struct dcd_genericobj *gen_obj) {int status =0 ; -char seps[] =", " ; +static const char seps[] =", " ;char *psz_cur;char *token;s32 token_len =0 ;
@@ -1419,7 +1419,7 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,u32 ul_addr =0 ;/* Used by cod_get_section */ u32 ul_len =0 ;/* Used by cod_get_section */ u32 dw_data_size =COD_MAXPATHLENGTH ; -char seps[] =", " ; +static const char seps[] =", " ;char *token =NULL ;bool get_uuids = (dep_lib_uuids !=NULL );u16 dep_libs =0 ;
Signature · 1 line
1.7.3.rc1
PATCH 20/25 drivers/usb: Use static const char arrays
In reply to Joe Perches--- drivers/usb/atm/ueagle-atm.c | 14 +++++--------- drivers/usb/otg/langwell_otg.c | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/usb/atm/ueagle-atm.c +5 -9
@@ -1574,20 +1574,16 @@ static int uea_stat_e4(struct uea_softc *sc)static void cmvs_file_name (struct uea_softc *sc,char *const cmv_name,int ver) { -char file_arr[] ="CMVxy.bin" ; +char file_arr[sizeof ("CMVxy.bin" )];char *file;kparam_block_sysfs_write (cmv_file);/* set proper name corresponding modem version and line type */ if (cmv_file[sc->modem_index] ==NULL ) { -if (UEA_CHIP_VERSION (sc) ==ADI930 ) - file_arr[3 ] ='9' ; -else if (UEA_CHIP_VERSION (sc) ==EAGLE_IV ) - file_arr[3 ] ='4' ; -else - file_arr[3 ] ='e' ; - - file_arr[4 ] =IS_ISDN (sc) ?'i' :'p' ; +sprintf (file_arr,"CMV%c%c.bin" , + (UEA_CHIP_VERSION (sc) ==ADI930 ) ?'9' : + (UEA_CHIP_VERSION (sc) ==EAGLE_IV ) ?'4' :'e' , +IS_ISDN (sc) ?'i' :'p' ); file = file_arr; }else file = cmv_file[sc->modem_index];
drivers/usb/otg/langwell_otg.c +1 -1
@@ -2035,7 +2035,7 @@ static int langwell_otg_probe(struct pci_dev *pdev,int retval;u32 val32;struct langwell_otg *lnw; -char qname[] ="langwell_otg_queue" ; +static const char qname[] ="langwell_otg_queue" ; retval =0 ;dev_dbg (&pdev->dev,"\notg controller is detected.\n" );
Signature · 1 line
1.7.3.rc1
Re: [PATCH 20/25] drivers/usb: Use static const char arrays
Quoted 23 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- drivers/usb/atm/ueagle-atm.c | 14 +++++--------- drivers/usb/otg/langwell_otg.c | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-)drivers/usb/atm/ueagle-atm.c +1
-3@@ -1574,20 +1574,16 @@ static int uea_stat_e4(struct uea_softc *sc)static void cmvs_file_name (struct uea_softc *sc,char *const cmv_name,int ver) { -char file_arr[] ="CMVxy.bin" ; +char file_arr[sizeof ("CMVxy.bin" )];char *file;kparam_block_sysfs_write (cmv_file);/* set proper name corresponding modem version and line type */ if (cmv_file[sc->modem_index] ==NULL ) { -if (UEA_CHIP_VERSION (sc) ==ADI930 ) - file_arr[3 ] ='9' ;
drivers/usb/atm/ueagle-atm.c static int uea_stat_e4(struct uea_softc *sc) · line 1586
Quoted 10 lines
drivers/usb/atm/ueagle-atm.c +4
-6-else if (UEA_CHIP_VERSION (sc) ==EAGLE_IV ) - file_arr[3 ] ='4' ; -else - file_arr[3 ] ='e' ; - - file_arr[4 ] =IS_ISDN (sc) ?'i' :'p' ; +sprintf (file_arr,"CMV%c%c.bin" , + (UEA_CHIP_VERSION (sc) ==ADI930 ) ?'9' : + (UEA_CHIP_VERSION (sc) ==EAGLE_IV ) ?'4' :'e' , +IS_ISDN (sc) ?'i' :'p' );
I despise : ? logic wherever possible, so no, I will not take this patch, sorry.
thanks,
greg k-h
PATCH 21/25 drivers/video: Use static const char arrays
In reply to Joe Perches--- drivers/video/sh_mipi_dsi.c | 4 ++-- drivers/video/sis/sis_main.c | 10 +++++----- drivers/video/via/viafbdev.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/video/sh_mipi_dsi.c +2 -2
@@ -319,7 +319,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev)struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );unsigned long rate, f_current;int idx = pdev->id, ret; -char dsip_clk[] ="dsi.p_clk" ; +char dsip_clk[sizeof ("dsiXp_clk" )];if (!res || idx >=ARRAY_SIZE (mipi_dsi) || !pdata)return -ENODEV ;
@@ -370,7 +370,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"DSI-T clk %lu -> %lu\n" , f_current, rate); -sprintf (dsip_clk,"dsi%1.1dp_clk" , idx); +sprintf (dsip_clk,"dsi%cp_clk" , idx +'0' ); mipi->dsip_clk =clk_get (&pdev->dev, dsip_clk);if (IS_ERR (mipi->dsip_clk)) { ret =PTR_ERR (mipi->dsip_clk);
drivers/video/sis/sis_main.c +5 -5
@@ -2387,8 +2387,8 @@ SiS_Sense30x(struct sis_video_info *ivideo)u16 cvbs=0 , cvbs_c=0 ;u16 vga2=0 , vga2_c=0 ;int myflag, result; -char stdstr[] ="sisfb: Detected" ; -char tvstr[] ="TV connected to" ; +static const char stdstr[] ="sisfb: Detected" ; +static const char tvstr[] ="TV connected to" ;if (ivideo->vbflags2 &VB2_301 ) { svhs =0x00b9 ; cvbs =0x00b3 ; vga2 =0x00d1 ;
@@ -2525,7 +2525,7 @@ SiS_SenseCh(struct sis_video_info *ivideo) {#if defined(CONFIG_FB_SIS_300 ) || defined(CONFIG_FB_SIS_315 )u8 temp1, temp2; -char stdstr[] ="sisfb: Chrontel: Detected TV connected to" ; +static const char stdstr[] ="sisfb: Chrontel: Detected TV connected to" ;#endif #ifdef CONFIG_FB_SIS_300 unsigned char test[3 ];
@@ -2648,8 +2648,8 @@ SiS_SenseCh(struct sis_video_info *ivideo)static void __devinit sisfb_get_VB_type (struct sis_video_info *ivideo) { -char stdstr[] ="sisfb: Detected" ; -char bridgestr[] ="video bridge" ; +static const char stdstr[] ="sisfb: Detected" ; +static const char bridgestr[] ="video bridge" ;u8 vb_chipid;u8 reg;
drivers/video/via/viafbdev.c +1 -1
@@ -367,7 +367,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) } u;u32 state_info =0 ;u32 *viafb_gamma_table; -char driver_name[] ="viafb" ; +static const char driver_name[] ="viafb" ;u32 __user *argp = (u32 __user *) arg;u32 gpu32;
Signature · 1 line
1.7.3.rc1
Re: [PATCH 21/25] drivers/video: Use static const char arrays
Quoted 2 lines
Signed-off-by Joe Perches <[email protected]>
Quoted 84 lines
--- drivers/video/sh_mipi_dsi.c | 4 ++-- drivers/video/sis/sis_main.c | 10 +++++----- drivers/video/via/viafbdev.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)drivers/video/sh_mipi_dsi.c +2
-2@@ -319,7 +319,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev)struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );unsigned long rate, f_current;int idx = pdev->id, ret; -char dsip_clk[] ="dsi.p_clk" ; +char dsip_clk[sizeof ("dsiXp_clk" )];if (!res || idx >=ARRAY_SIZE (mipi_dsi) || !pdata)return -ENODEV ;@@ -370,7 +370,7 @@ static int __init sh_mipi_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"DSI-T clk %lu -> %lu\n" , f_current, rate); -sprintf (dsip_clk,"dsi%1.1dp_clk" , idx); +sprintf (dsip_clk,"dsi%cp_clk" , idx +'0' ); mipi->dsip_clk =clk_get (&pdev->dev, dsip_clk);if (IS_ERR (mipi->dsip_clk)) { ret =PTR_ERR (mipi->dsip_clk);drivers/video/sis/sis_main.c +5
-5@@ -2387,8 +2387,8 @@ SiS_Sense30x(struct sis_video_info *ivideo)u16 cvbs=0 , cvbs_c=0 ;u16 vga2=0 , vga2_c=0 ;int myflag, result; -char stdstr[] ="sisfb: Detected" ; -char tvstr[] ="TV connected to" ; +static const char stdstr[] ="sisfb: Detected" ; +static const char tvstr[] ="TV connected to" ;if (ivideo->vbflags2 &VB2_301 ) { svhs =0x00b9 ; cvbs =0x00b3 ; vga2 =0x00d1 ;@@ -2525,7 +2525,7 @@ SiS_SenseCh(struct sis_video_info *ivideo) {#if defined(CONFIG_FB_SIS_300 ) || defined(CONFIG_FB_SIS_315 )u8 temp1, temp2; -char stdstr[] ="sisfb: Chrontel: Detected TV connected to" ; +static const char stdstr[] ="sisfb: Chrontel: Detected TV connected to" ;#endif #ifdef CONFIG_FB_SIS_300 unsigned char test[3 ];@@ -2648,8 +2648,8 @@ SiS_SenseCh(struct sis_video_info *ivideo)static void __devinit sisfb_get_VB_type (struct sis_video_info *ivideo) { -char stdstr[] ="sisfb: Detected" ; -char bridgestr[] ="video bridge" ; +static const char stdstr[] ="sisfb: Detected" ; +static const char bridgestr[] ="video bridge" ;u8 vb_chipid;u8 reg;drivers/video/via/viafbdev.c +1
-1@@ -367,7 +367,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) } u;u32 state_info =0 ;u32 *viafb_gamma_table; -char driver_name[] ="viafb" ; +static const char driver_name[] ="viafb" ;u32 __user *argp = (u32 __user *) arg;u32 gpu32;Signature · 6 lines
1.7.3.rc1 -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 22/25 net/dsa: Use static const char arrays
In reply to Joe Perches--- net/dsa/dsa.c | 2 +- net/dsa/dsa_priv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/dsa/dsa.c +1 -1
@@ -15,7 +15,7 @@#include <net/dsa.h> #include "dsa_priv.h" -char dsa_driver_version[] ="0.1" ; +const char dsa_driver_version[] ="0.1" ;/* switch driver registration ***********************************************/
net/dsa/dsa_priv.h +1 -1
@@ -158,7 +158,7 @@ struct dsa_switch_driver { };/* dsa.c */ -extern char dsa_driver_version[]; +extern const char dsa_driver_version[];void register_switch_driver (struct dsa_switch_driver *type);void unregister_switch_driver (struct dsa_switch_driver *type);
Signature · 1 line
1.7.3.rc1
PATCH 23/25 net/sunrpc: Use static const char arrays
In reply to Joe Perches--- net/sunrpc/auth_gss/gss_krb5_mech.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/sunrpc/auth_gss/gss_krb5_mech.c +1 -1
@@ -422,7 +422,7 @@ static int context_derive_keys_rc4(struct krb5_ctx *ctx) {struct crypto_hash *hmac; -char sigkeyconstant[] ="signaturekey" ; +static const char sigkeyconstant[] ="signaturekey" ;int slen =strlen (sigkeyconstant) +1 ;/* include null terminator */ struct hash_desc desc;struct scatterlist sg[1 ];
Signature · 1 line
1.7.3.rc1
PATCH 24/25 sound: Use static const char arrays
In reply to Joe Perches--- sound/core/misc.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
sound/core/misc.c +4 -1
@@ -64,12 +64,15 @@ static int print_snd_pfx(unsigned int level, const char *path, int line, const char *format) {const char *file =sanity_file_name (path); -char tmp[] ="<0>" ; +char tmp[sizeof ("<0>" )];const char *pfx = level ?KERN_DEBUG :KERN_DEFAULT ;int ret =0 ;if (format[0 ] =='<' && format[2 ] =='>' ) { + tmp[0 ] ='<' ; tmp[1 ] = format[1 ]; + tmp[2 ] ='>' ; + tmp[3 ] =0 ; pfx = tmp; ret =1 ; }
Signature · 1 line
1.7.3.rc1
Re: [PATCH 24/25] sound: Use static const char arrays
At Mon, 13 Sep 2010 12:48:02 -0700,
Quoted 17 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- sound/core/misc.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)sound/core/misc.c +1
-1@@ -64,12 +64,15 @@ static int print_snd_pfx(unsigned int level, const char *path, int line, const char *format) {const char *file =sanity_file_name (path); -char tmp[] ="<0>" ; +char tmp[sizeof ("<0>" )];const char *pfx = level ?KERN_DEBUG :KERN_DEFAULT ;
sound/core/misc.c static int print_snd_pfx(unsigned int level, const char *path, int line, · line 78
Quoted 10 lines
sound/core/misc.c +3
-0int ret =0 ;if (format[0 ] =='<' && format[2 ] =='>' ) { + tmp[0 ] ='<' ; tmp[1 ] = format[1 ]; + tmp[2 ] ='>' ; + tmp[3 ] =0 ; pfx = tmp; ret =1 ; }
Would this case save something really...?
thanks,
Takashi
Re: [PATCH 24/25] sound: Use static const char arrays
Quoted 6 lines · Takashi Iwai
At Mon, 13 Sep 2010 12:48:02 -0700,
sound/core/misc.c static int print_snd_pfx(unsigned int level, const char *path, int line, · line 67
Quoted 3 lines · Joe Perches
sound/core/misc.c +1
-1-char tmp[] ="<0>" ; +char tmp[sizeof ("<0>" )];Would this case save something really...?
Not really. It's the same x86 code size with different opcodes. It's just a stupid checkpatch future warning avoidance change. Ignore it at your pleasure.
cheers, Joe
Re: [PATCH 24/25] sound: Use static const char arrays
At Mon, 13 Sep 2010 13:47:45 -0700,
Quoted 4 lines · Joe Perches
Quoted 2 lines · Takashi Iwai
At Mon, 13 Sep 2010 12:48:02 -0700,
Joe Perches wrote:
Quoted 8 lines
Quoted 4 lines
sound/core/misc.c static int print_snd_pfx(unsigned int level, const char *path, int line, · line 67
Quoted 3 lines
sound/core/misc.c +1
-1-char tmp[] ="<0>" ; +char tmp[sizeof ("<0>" )];Would this case save something really...?
Not really. It's the same x86 code size with different opcodes. It's just a stupid checkpatch future warning avoidance change. Ignore it at your pleasure.
OK, then let's postpone.
The current code is indeed not sexy, but the patch won't improve the readability much, too ;)
thanks,
Takashi
PATCH 25/25 tools/perf/util: Use static const char arrays
In reply to Joe Perches--- tools/perf/util/ui/setup.c | 3 ++- tools/perf/util/ui/util.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/ui/setup.c +2 -1
@@ -34,7 +34,8 @@ void exit_browser(bool wait_for_ok) {if (use_browser >0 ) {if (wait_for_ok) { -char title[] ="Fatal Error" , ok[] ="Ok" ; +static const char title[] ="Fatal Error" ; +static const char ok[] ="Ok" ;newtWinMessage (title, ok, ui_helpline__last_msg); }newtFinished ();
tools/perf/util/ui/util.c +2 -1
@@ -107,6 +107,7 @@ out_destroy_form:bool ui__dialog_yesno (const char *msg) {/* newtWinChoice should really be accepting const char pointers... */ -char yes[] ="Yes" , no[] ="No" ; +static const char yes[] ="Yes" ; +static const char no[] ="No" ;return newtWinChoice (NULL , yes, no, (char *)msg) ==1 ; }
Signature · 1 line
1.7.3.rc1
(unknown)
In reply to Joe PerchesQuoted 2 lines · Joe Perches
Using static const char foo[] = "bar" can save some code and text space, so change the places where it's possible.
That's reasonable.
Quoted 8 lines
Also change the places that use
char foo[] = "barX"; ... foo[3] = value + '0'; where X is typically changed char foo[sizeof("barX")]; ... sprintf(foo, "bar%c", value + '0');
You haven't said what this gains. I can see what it may cost, though (depending on how gcc loads foo[]).
David