[alsa-devel] Missing return check of of_property_read_*()

Takashi Iwai tiwai at suse.de
Wed Sep 9 16:40:36 CEST 2015


Hi,

I hoped that I wouldn't need to write this kind of post, but since
nothing happened so far, so here we go:

The following compile warnings are present for quite some time.  They
are due to the lack of return check from of_property_read*().

sound/soc/codecs/cs35l32.c: In function ‘cs35l32_i2c_probe’:
sound/soc/codecs/cs35l32.c:278:2: warning: ‘val’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  switch (val) {
  ^
sound/soc/codecs/cs35l32.c:272:15: note: ‘val’ was declared here
  unsigned int val;
               ^

sound/soc/sti/uniperif_player.c: In function ‘uni_player_init’:
sound/soc/sti/uniperif_player.c:1006:6: warning: ‘mode’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (strcasecmp(mode, "hdmi") == 0)
      ^
sound/soc/sti/uniperif_player.c:985:14: note: ‘mode’ was declared here
  const char *mode;
              ^

Both should be trivial to fix, but I won't bother to fix these things
by myself, as it results always in a matter of taste how to write.
So, please fix them appropriately.


Although not shown as compile warning like the above, lots of codec
drivers have no return value checks from of_property_read*(), too.
A quick grep reveals:

% git grep -B1 '^[[:space:]]*of_property_read_' sound/soc
sound/soc/codecs/adau1701.c-
sound/soc/codecs/adau1701.c:		of_property_read_u32(dev->of_node, "adi,pll-clkdiv",
--
sound/soc/codecs/adau1701.c-
sound/soc/codecs/adau1701.c:		of_property_read_u8_array(dev->of_node, "adi,pin-config",
--
sound/soc/codecs/cs35l32.c-
sound/soc/codecs/cs35l32.c:	of_property_read_u32(np, "cirrus,boost-manager", &val);
--
sound/soc/codecs/cs35l32.c-
sound/soc/codecs/cs35l32.c:	of_property_read_u32(np, "cirrus,sdout-datacfg", &val);
--
sound/soc/codecs/cs35l32.c-
sound/soc/codecs/cs35l32.c:	of_property_read_u32(np, "cirrus,battery-threshold", &val);
--
sound/soc/codecs/cs35l32.c-
sound/soc/codecs/cs35l32.c:	of_property_read_u32(np, "cirrus,battery-recovery", &val);
--
sound/soc/codecs/sta32x.c-
sound/soc/codecs/sta32x.c:	of_property_read_u8(np, "st,output-conf",
sound/soc/codecs/sta32x.c-			    &pdata->output_conf);
sound/soc/codecs/sta32x.c:	of_property_read_u8(np, "st,ch1-output-mapping",
sound/soc/codecs/sta32x.c-			    &pdata->ch1_output_mapping);
sound/soc/codecs/sta32x.c:	of_property_read_u8(np, "st,ch2-output-mapping",
sound/soc/codecs/sta32x.c-			    &pdata->ch2_output_mapping);
sound/soc/codecs/sta32x.c:	of_property_read_u8(np, "st,ch3-output-mapping",
--
sound/soc/codecs/sta32x.c-	tmp = 140;
sound/soc/codecs/sta32x.c:	of_property_read_u16(np, "st,drop-compensation-ns", &tmp);
--
sound/soc/codecs/sta350.c-
sound/soc/codecs/sta350.c:	of_property_read_u8(np, "st,output-conf",
sound/soc/codecs/sta350.c-			    &pdata->output_conf);
sound/soc/codecs/sta350.c:	of_property_read_u8(np, "st,ch1-output-mapping",
sound/soc/codecs/sta350.c-			    &pdata->ch1_output_mapping);
sound/soc/codecs/sta350.c:	of_property_read_u8(np, "st,ch2-output-mapping",
sound/soc/codecs/sta350.c-			    &pdata->ch2_output_mapping);
sound/soc/codecs/sta350.c:	of_property_read_u8(np, "st,ch3-output-mapping",
--
sound/soc/codecs/sta350.c-	tmp = 140;
sound/soc/codecs/sta350.c:	of_property_read_u16(np, "st,drop-compensation-ns", &tmp);
--
sound/soc/codecs/tas5086.c-
sound/soc/codecs/tas5086.c:		of_property_read_u32(of_node, "ti,charge-period",
--
sound/soc/codecs/tlv320aic31xx.c-
sound/soc/codecs/tlv320aic31xx.c:	of_property_read_u32(np, "ai31xx-micbias-vg", &value);
--
sound/soc/codecs/twl4030.c-
sound/soc/codecs/twl4030.c:	of_property_read_u32(node, "ti,digimic_delay",
sound/soc/codecs/twl4030.c-			     &pdata->digimic_delay);
sound/soc/codecs/twl4030.c:	of_property_read_u32(node, "ti,ramp_delay_value",
sound/soc/codecs/twl4030.c-			     &pdata->ramp_delay_value);
sound/soc/codecs/twl4030.c:	of_property_read_u32(node, "ti,offset_cncl_path",
--
sound/soc/fsl/fsl_esai.c-	esai_priv->synchronous =
sound/soc/fsl/fsl_esai.c:		of_property_read_bool(np, "fsl,esai-synchronous");
--
sound/soc/omap/omap-abe-twl6040.c-	priv->jack_detection = of_property_read_bool(node, "ti,jack-detection");
sound/soc/omap/omap-abe-twl6040.c:	of_property_read_u32(node, "ti,mclk-freq", &priv->mclk_freq);
--
sound/soc/samsung/i2s.c-	}
sound/soc/samsung/i2s.c:	of_property_read_string_index(dev->of_node,
--
sound/soc/sh/rcar/rsrc-card.c-	/* sampling rate convert */
sound/soc/sh/rcar/rsrc-card.c:	of_property_read_u32(node, "convert-rate", &priv->convert_rate);
--
sound/soc/sti/uniperif_player.c-
sound/soc/sti/uniperif_player.c:	of_property_read_u32(pnode, "version", &player->ver);
--
sound/soc/sti/uniperif_player.c-
sound/soc/sti/uniperif_player.c:	of_property_read_u32(pnode, "uniperiph-id", &info->id);
--
sound/soc/sti/uniperif_player.c-	/* Read the device mode property */
sound/soc/sti/uniperif_player.c:	of_property_read_string(pnode, "mode", &mode);
--
sound/soc/sti/uniperif_reader.c-
sound/soc/sti/uniperif_reader.c:	of_property_read_u32(node, "version", &reader->ver);


Many of them look really buggy (while some have the default value to
fall back).  And many codes have even no value checks.  These should
be fixed as well.


thanks,

Takashi


More information about the Alsa-devel mailing list