[alsa-devel] [PATCH 1/5] sound: serial-u16550: fix uninitialized variable warning
Fix sound/drivers/serial-u16550.c:905: warning: 'uart' may be used uninitialized in this function
Signed-off-by: Bill Pemberton wfp5p@virginia.edu --- sound/drivers/serial-u16550.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index a25fb7b..5f8ae28 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -902,7 +902,7 @@ static int __devinit snd_uart16550_rmidi(struct snd_uart16550 *uart, int device, static int __devinit snd_serial_probe(struct platform_device *devptr) { struct snd_card *card; - struct snd_uart16550 *uart; + struct snd_uart16550 *uninitialized_var(uart); int err; int dev = devptr->id;
quiet the warning: sound/pci/atiixp.c:1652: warning: 'chip' may be used uninitialized in this function
chip is set by snd_atiixp_create()
Signed-off-by: Bill Pemberton wfp5p@virginia.edu --- sound/pci/atiixp_modem.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 91d7036..ef9524a 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1285,7 +1285,7 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { struct snd_card *card; - struct atiixp_modem *chip; + struct atiixp_modem *uninitialized_var(chip); int err;
err = snd_card_create(index, id, THIS_MODULE, 0, &card);
quiet the warning: sound/pci/via82xx_modem.c:1168: warning: 'chip' may be used uninitialized in this function
chip is set by snd_via82xx_create()
Signed-off-by: Bill Pemberton wfp5p@virginia.edu --- sound/pci/via82xx_modem.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index f7e8bbbe..11eebcc 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1165,7 +1165,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { struct snd_card *card; - struct via82xx_modem *chip; + struct via82xx_modem *uninitialized_var(chip); int chip_type = 0, card_type; unsigned int i; int err;
quiet the warning: sound/pci/via82xx.c:2498: warning: 'chip' may be used uninitialized in this function
chip is set by snd_via82xx_create()
Signed-off-by: Bill Pemberton wfp5p@virginia.edu --- sound/pci/via82xx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 8c5f8b5..f7d02fc 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2500,7 +2500,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { struct snd_card *card; - struct via82xx *chip; + struct via82xx *uninitialized_var(chip); int chip_type = 0, card_type; unsigned int i; int err;
quiet the warning about use of uninitialized fll_div in wm8900_set_fll. fll_div is initialized by fll_factors()
Signed-off-by: Bill Pemberton wfp5p@virginia.edu --- sound/soc/codecs/wm8900.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 5da17a7..f1840c6 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -746,7 +746,7 @@ static int wm8900_set_fll(struct snd_soc_codec *codec, int fll_id, unsigned int freq_in, unsigned int freq_out) { struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); - struct _fll_div fll_div; + struct _fll_div uninitialized_var(fll_div); unsigned int reg;
if (wm8900->fll_in == freq_in && wm8900->fll_out == freq_out)
On Tue, Aug 03, 2010 at 03:20:26PM -0400, Bill Pemberton wrote:
quiet the warning about use of uninitialized fll_div in wm8900_set_fll. fll_div is initialized by fll_factors()
Signed-off-by: Bill Pemberton wfp5p@virginia.edu
Always remember to CC maintainers on patches as covered in SubmittingPatches.
sound/soc/codecs/wm8900.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 5da17a7..f1840c6 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -746,7 +746,7 @@ static int wm8900_set_fll(struct snd_soc_codec *codec, int fll_id, unsigned int freq_in, unsigned int freq_out) { struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec);
- struct _fll_div fll_div;
- struct _fll_div uninitialized_var(fll_div); unsigned int reg;
No, just stomping over the variable to shut up the warning doesn't improve anything at all. You need to make sure that the compiler can actually follow the control flow to see that the data is always initialised rather than disabling the check and missing any actual issues.
I rather suspect this is just a bug in your compiler's flow analysis, it's not showing up with GCC 4.3.3 on ARM for me.
At Wed, 4 Aug 2010 10:02:24 +0100, Mark Brown wrote:
On Tue, Aug 03, 2010 at 03:20:26PM -0400, Bill Pemberton wrote:
quiet the warning about use of uninitialized fll_div in wm8900_set_fll. fll_div is initialized by fll_factors()
Signed-off-by: Bill Pemberton wfp5p@virginia.edu
Always remember to CC maintainers on patches as covered in SubmittingPatches.
sound/soc/codecs/wm8900.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 5da17a7..f1840c6 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -746,7 +746,7 @@ static int wm8900_set_fll(struct snd_soc_codec *codec, int fll_id, unsigned int freq_in, unsigned int freq_out) { struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec);
- struct _fll_div fll_div;
- struct _fll_div uninitialized_var(fll_div); unsigned int reg;
No, just stomping over the variable to shut up the warning doesn't improve anything at all. You need to make sure that the compiler can actually follow the control flow to see that the data is always initialised rather than disabling the check and missing any actual issues.
I rather suspect this is just a bug in your compiler's flow analysis, it's not showing up with GCC 4.3.3 on ARM for me.
Yes, the uninitialized_var() thing is rarely useful because most cases are false-positive. If such an initialization is really needed, often it indicates the need of refactoring.
All the patches posted here look unnecessary, so I'd like to skip.
thanks,
Takashi
participants (3)
-
Bill Pemberton
-
Mark Brown
-
Takashi Iwai