* [Kernel-janitors] [PATCH] Fix warning in drivers/ide/pci/triflex.c
@ 2004-01-23 16:09 Luiz Fernando Capitulino
2004-01-26 16:06 ` Felipe W Damasio
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Luiz Fernando Capitulino @ 2004-01-23 16:09 UTC (permalink / raw)
To: kernel-janitors
hi all,
this patch fixes this warning:
drivers/ide/pci/triflex.c:49: warning: `triflex_get_info' defined but not used
here is:
diff -X dontdiff -Nru linux-2.6.2-rc2/drivers/ide/pci/triflex.c linux-2.6.2-rc2~/drivers/ide/pci/triflex.c
--- linux-2.6.2-rc2/drivers/ide/pci/triflex.c 2003-10-08 16:24:04.000000000 -0300
+++ linux-2.6.2-rc2~/drivers/ide/pci/triflex.c 2004-01-26 11:02:33.000000000 -0200
@@ -45,6 +45,7 @@
static struct pci_dev *triflex_dev;
+#ifdef CONFIG_PROC_FS
static int triflex_get_info(char *buf, char **addr, off_t offset, int count)
{
char *p = buf;
@@ -91,6 +92,7 @@
return len > count ? count : len;
}
+#endif
static int triflex_tune_chipset(ide_drive_t *drive, u8 xferspeed)
{
diff -X dontdiff -Nru linux-2.6.2-rc2/drivers/ide/pci/triflex.h linux-2.6.2-rc2~/drivers/ide/pci/triflex.h
--- linux-2.6.2-rc2/drivers/ide/pci/triflex.h 2003-10-08 16:24:26.000000000 -0300
+++ linux-2.6.2-rc2~/drivers/ide/pci/triflex.h 2004-01-26 11:02:33.000000000 -0200
@@ -14,8 +14,16 @@
static unsigned int __devinit init_chipset_triflex(struct pci_dev *, const char *);
static void init_hwif_triflex(ide_hwif_t *);
+#ifdef CONFIG_PROC_FS
static int triflex_get_info(char *, char **, off_t, int);
+static ide_pci_host_proc_t triflex_proc __initdata = {
+ .name = "triflex",
+ .set = 1,
+ .get_info = triflex_get_info,
+};
+#endif
+
static ide_pci_device_t triflex_devices[] __devinitdata = {
{
.vendor = PCI_VENDOR_ID_COMPAQ,
@@ -33,14 +41,6 @@
}
};
-#ifdef CONFIG_PROC_FS
-static ide_pci_host_proc_t triflex_proc __initdata = {
- .name = "triflex",
- .set = 1,
- .get_info = triflex_get_info,
-};
-#endif
-
static struct pci_device_id triflex_pci_tbl[] = {
{ PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE, PCI_ANY_ID,
PCI_ANY_ID, 0, 0, 0 },
--
Luiz Fernando N. Capitulino
<lcapitulino@prefeitura.sp.gov.br>
<http://www.telecentros.sp.gov.br>
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Kernel-janitors] [PATCH] Fix warning in drivers/ide/pci/triflex.c
2004-01-23 16:09 [Kernel-janitors] [PATCH] Fix warning in drivers/ide/pci/triflex.c Luiz Fernando Capitulino
@ 2004-01-26 16:06 ` Felipe W Damasio
2004-01-29 19:05 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c when Luiz Fernando Capitulino
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Felipe W Damasio @ 2004-01-26 16:06 UTC (permalink / raw)
To: kernel-janitors
Greetings,
Luiz Fernando Capitulino wrote:
> hi all,
>
> this patch fixes this warning:
>
> drivers/ide/pci/triflex.c:49: warning: `triflex_get_info' defined but not used
>
> here is:
>
> diff -X dontdiff -Nru linux-2.6.2-rc2/drivers/ide/pci/triflex.c linux-2.6.2-rc2~/drivers/ide/pci/triflex.c
> --- linux-2.6.2-rc2/drivers/ide/pci/triflex.c 2003-10-08 16:24:04.000000000 -0300
> +++ linux-2.6.2-rc2~/drivers/ide/pci/triflex.c 2004-01-26 11:02:33.000000000 -0200
> @@ -45,6 +45,7 @@
>
> static struct pci_dev *triflex_dev;
>
> +#ifdef CONFIG_PROC_FS
> static int triflex_get_info(char *buf, char **addr, off_t offset, int count)
> {
> char *p = buf;
> @@ -91,6 +92,7 @@
>
> return len > count ? count : len;
> }
> +#endif
Do we really need this chunk?
> static int triflex_tune_chipset(ide_drive_t *drive, u8 xferspeed)
> {
> diff -X dontdiff -Nru linux-2.6.2-rc2/drivers/ide/pci/triflex.h linux-2.6.2-rc2~/drivers/ide/pci/triflex.h
> --- linux-2.6.2-rc2/drivers/ide/pci/triflex.h 2003-10-08 16:24:26.000000000 -0300
> +++ linux-2.6.2-rc2~/drivers/ide/pci/triflex.h 2004-01-26 11:02:33.000000000 -0200
> @@ -14,8 +14,16 @@
>
> static unsigned int __devinit init_chipset_triflex(struct pci_dev *, const char *);
> static void init_hwif_triflex(ide_hwif_t *);
> +#ifdef CONFIG_PROC_FS
> static int triflex_get_info(char *, char **, off_t, int);
.
.
.
> +#endif
Since triflex_get_info is already #ifdef'd out if CONFIG_PROC_FS is not
set, we don't need to put that extra #ifdef on the .c file, since that
function will not get used anyway.
IIRC the policy for adding #ifdefs on .c files is when it's really
necessary, and I don't really see the point for this (expect object size
and an extra symbol defined, which I don't think it really hurts here).
Cheers,
Felipe
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c when
2004-01-23 16:09 [Kernel-janitors] [PATCH] Fix warning in drivers/ide/pci/triflex.c Luiz Fernando Capitulino
2004-01-26 16:06 ` Felipe W Damasio
@ 2004-01-29 19:05 ` Luiz Fernando Capitulino
2004-01-30 11:04 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c Luiz Fernando Capitulino
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Fernando Capitulino @ 2004-01-29 19:05 UTC (permalink / raw)
To: kernel-janitors
hi,
When !CONFIG_PROC_FS, I'm getting this warning:
drivers/net/pppoe.c: In function `pppoe_init':
drivers/net/pppoe.c:1132: warning: label `out_unregister' defined but not used
this patch fixes that and removes a #ifdef/#endif inside a function. I
would like to hear comments about it.
diff -X dontdiff -Nru linux-2.6.2-rc2/drivers/net/pppoe.c linux-2.6.2-rc2~/drivers/net/pppoe.c
--- linux-2.6.2-rc2/drivers/net/pppoe.c 2004-01-29 09:19:48.000000000 -0200
+++ linux-2.6.2-rc2~/drivers/net/pppoe.c 2004-01-29 09:24:30.000000000 -0200
@@ -1076,6 +1076,20 @@
.llseek = seq_lseek,
.release = seq_release,
};
+
+static int __init pppoe_proc_init(void)
+{
+ struct proc_dir_entry *p = create_proc_entry("pppoe", S_IRUGO,
+ proc_net);
+
+ if (!p)
+ return 0;
+
+ p->proc_fops = &pppoe_seq_fops;
+ return 1;
+}
+#else /* CONFIG_PROC_FS */
+static int inline pppoe_proc_init(void) { return 0; }
#endif /* CONFIG_PROC_FS */
/* ->ioctl are set at pppox_create */
@@ -1112,18 +1126,11 @@
if (err)
goto out;
-#ifdef CONFIG_PROC_FS
-{
- struct proc_dir_entry *p = create_proc_entry("pppoe", S_IRUGO,
- proc_net);
+
err = -ENOMEM;
- if (!p)
+ if (!(err = pppoe_proc_init()))
goto out_unregister;
- p->proc_fops = &pppoe_seq_fops;
- err = 0;
-}
-#endif /* CONFIG_PROC_FS */
dev_add_pack(&pppoes_ptype);
dev_add_pack(&pppoed_ptype);
register_netdevice_notifier(&pppoe_notifier);
--
Luiz Fernando N. Capitulino
<lcapitulino@prefeitura.sp.gov.br>
<http://www.telecentros.sp.gov.br>
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c
2004-01-23 16:09 [Kernel-janitors] [PATCH] Fix warning in drivers/ide/pci/triflex.c Luiz Fernando Capitulino
2004-01-26 16:06 ` Felipe W Damasio
2004-01-29 19:05 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c when Luiz Fernando Capitulino
@ 2004-01-30 11:04 ` Luiz Fernando Capitulino
2004-02-02 22:03 ` [Kernel-janitors] [PATCH] Fix warning indrivers/ide/pci/triflex.c Adrian Bunk
2004-02-06 13:10 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c when Luiz Fernando Capitulino
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Fernando Capitulino @ 2004-01-30 11:04 UTC (permalink / raw)
To: kernel-janitors
Em Qui, 2004-01-29 às 17:05, Luiz Fernando Capitulino escreveu:
> +
> err = -ENOMEM;
> - if (!p)
> + if (!(err = pppoe_proc_init()))
> goto out_unregister;
I did a study thing in the handling of 'err', I will rediff.
--
Luiz Fernando N. Capitulino
<lcapitulino@prefeitura.sp.gov.br>
<http://www.telecentros.sp.gov.br>
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Kernel-janitors] [PATCH] Fix warning indrivers/ide/pci/triflex.c
2004-01-23 16:09 [Kernel-janitors] [PATCH] Fix warning in drivers/ide/pci/triflex.c Luiz Fernando Capitulino
` (2 preceding siblings ...)
2004-01-30 11:04 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c Luiz Fernando Capitulino
@ 2004-02-02 22:03 ` Adrian Bunk
2004-02-06 13:10 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c when Luiz Fernando Capitulino
4 siblings, 0 replies; 6+ messages in thread
From: Adrian Bunk @ 2004-02-02 22:03 UTC (permalink / raw)
To: kernel-janitors
On Fri, Jan 23, 2004 at 03:06:46PM -0200, Luiz Fernando Capitulino wrote:
>...
> Em Seg, 2004-01-26 às 14:06, Felipe W Damasio escreveu:
>...
> > IIRC the policy for adding #ifdefs on .c files is when it's really
> > necessary, and I don't really see the point for this (expect object size
> > and an extra symbol defined, which I don't think it really hurts here).
>
> AFAIK, the _real_ problem is when you have #ifdef/#endif inside
> functions. I agree that is better to avoid it in .c files, but is not
> all the cases that it can be done.
Let's think about something different:
CONFIG_PROC_FS=n is _very_ unusual.
It's good that drivers compile and work with CONFIG_PROC_FS=n, and it's
also good to remove warnings in code.
But is it really worth uglifying code with #ifdef's to avoid a
completely harmless warning in a very unusual configuration?
> Luiz Fernando N. Capitulino
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c when
2004-01-23 16:09 [Kernel-janitors] [PATCH] Fix warning in drivers/ide/pci/triflex.c Luiz Fernando Capitulino
` (3 preceding siblings ...)
2004-02-02 22:03 ` [Kernel-janitors] [PATCH] Fix warning indrivers/ide/pci/triflex.c Adrian Bunk
@ 2004-02-06 13:10 ` Luiz Fernando Capitulino
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Fernando Capitulino @ 2004-02-06 13:10 UTC (permalink / raw)
To: kernel-janitors
Hi all,
here is the version 23.7 with Francois tips, actually I'm not
testing against (err < 0), because it is not necessary.
diff -Nru linux-2.6.2/drivers/net/pppoe.c linux-2.6.2~/drivers/net/pppoe.c
--- linux-2.6.2/drivers/net/pppoe.c 2004-02-05 08:42:32.000000000 -0200
+++ linux-2.6.2~/drivers/net/pppoe.c 2004-02-06 09:43:08.000000000 -0200
@@ -1076,6 +1076,20 @@
.llseek = seq_lseek,
.release = seq_release,
};
+
+static int __init pppoe_proc_init(void)
+{
+ struct proc_dir_entry *p;
+
+ p = create_proc_entry("pppoe", S_IRUGO, proc_net);
+ if (!p)
+ return -ENOMEM;
+
+ p->proc_fops = &pppoe_seq_fops;
+ return 0;
+}
+#else /* CONFIG_PROC_FS */
+static inline int pppoe_proc_init(void) { return 0; }
#endif /* CONFIG_PROC_FS */
/* ->ioctl are set at pppox_create */
@@ -1112,26 +1126,18 @@
if (err)
goto out;
-#ifdef CONFIG_PROC_FS
-{
- struct proc_dir_entry *p = create_proc_entry("pppoe", S_IRUGO,
- proc_net);
- err = -ENOMEM;
- if (!p)
- goto out_unregister;
+
+ err = pppoe_proc_init();
+ if (err) {
+ unregister_pppox_proto(PX_PROTO_OE);
+ goto out;
+ }
- p->proc_fops = &pppoe_seq_fops;
- err = 0;
-}
-#endif /* CONFIG_PROC_FS */
dev_add_pack(&pppoes_ptype);
dev_add_pack(&pppoed_ptype);
register_netdevice_notifier(&pppoe_notifier);
out:
return err;
-out_unregister:
- unregister_pppox_proto(PX_PROTO_OE);
- goto out;
}
static void __exit pppoe_exit(void)
--
Luiz Fernando N. Capitulino
<lcapitulino@prefeitura.sp.gov.br>
<http://www.telecentros.sp.gov.br>
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-02-06 13:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-23 16:09 [Kernel-janitors] [PATCH] Fix warning in drivers/ide/pci/triflex.c Luiz Fernando Capitulino
2004-01-26 16:06 ` Felipe W Damasio
2004-01-29 19:05 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c when Luiz Fernando Capitulino
2004-01-30 11:04 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c Luiz Fernando Capitulino
2004-02-02 22:03 ` [Kernel-janitors] [PATCH] Fix warning indrivers/ide/pci/triflex.c Adrian Bunk
2004-02-06 13:10 ` [Kernel-janitors] [PATCH] Fix warning in drivers/net/pppoe.c when Luiz Fernando Capitulino
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.