Skip to contentSkip to conversation

Trivial compile warning fixes

PATCH In review Takashi Iwai 2 participants 5 messages May 11, 2020

lore
Share & tools
lore
#0 lore raw

cover Trivial compile warning fixes

Hi,

here is a few patches to shut up trivial compile warnings that have been introduced recently.

Takashi

===

Takashi Iwai (3):
pcm: rate: Fix compile warning wrt bit ops and comparison
pcm: rate: Fix uninitialized variable warning
topology: Add missing ATTRIBUTE_UNUSED

 src/pcm/pcm_rate.c |  4 ++--
 src/topology/pcm.c | 18 ++++++++++--------
 2 files changed, 12 insertions(+), 10 deletions(-)
Signature · 1 line
2.16.4
#1 lore raw

PATCH 1/3 pcm: rate: Fix compile warning wrt bit ops and comparison

We've got a gcc warning:
pcm_rate.c: In function ‘snd_pcm_rate_drain’:
pcm_rate.c:1090:19: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]

     if (pcm->mode & SND_PCM_NONBLOCK != 0) {
                   ^

Drop the zero comparison for fixing the warning and for simplicity.

Fixes 29041c522071 ("fix infinite draining of the rate plugin in SND_PCM_NONBLOCK mode")
---
 src/pcm/pcm_rate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/pcm/pcm_rate.c +1 -1
index 4f99a95b325f..980fa44e4023 100644
@@ -1087,7 +1087,7 @@ static int snd_pcm_rate_drain(snd_pcm_t *pcm)
 				if (rate->last_commit_ptr >= pcm->boundary)
 					rate->last_commit_ptr = 0;
 			} else if (commit_err == 0) {
-				if (pcm->mode & SND_PCM_NONBLOCK != 0) {
+				if (pcm->mode & SND_PCM_NONBLOCK) {
 					commit_err = -EAGAIN;
 					break;
 				}
Signature · 1 line
2.16.4
#2 lore raw

PATCH 2/3 pcm: rate: Fix uninitialized variable warning

In reply to Takashi Iwai

The recent gcc warning indicates the uninitialized variable commit_err:
pcm_rate.c:1104:6: warning: ‘commit_err’ may be used uninitialized in this function [-Wmaybe-uninitialized]

     if (commit_err < 0)
         ^

Add a proper initialization to commit_err.

Fixes 29041c522071 ("fix infinite draining of the rate plugin in SND_PCM_NONBLOCK mode")
---
 src/pcm/pcm_rate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/pcm/pcm_rate.c +1 -1
index 980fa44e4023..9ec8c85ef13f 100644
@@ -1051,7 +1051,7 @@ static int snd_pcm_rate_drain(snd_pcm_t *pcm)
 		/* commit the remaining fraction (if any) */
 		snd_pcm_uframes_t size, ofs, saved_avail_min;
 		snd_pcm_sw_params_t sw_params;
-		int commit_err;
+		int commit_err = 0;
 
 		__snd_pcm_lock(pcm);
 		/* temporarily set avail_min to one */
Signature · 1 line
2.16.4
#3 lore raw

PATCH 3/3 topology: Add missing ATTRIBUTE_UNUSED

In reply to Takashi Iwai

... to shut up the compiler warnings.

Fixes b6c9afb4f59b ("topology: implement snd_tplg_decode")
---
 src/topology/pcm.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
src/topology/pcm.c +10 -8
index 61159d33357c..b15b95045ab5 100644
@@ -2053,20 +2053,22 @@ next:
 }
 
 /* decode dai from the binary input */
-int tplg_decode_dai(snd_tplg_t *tplg,
-		    size_t pos,
-		    struct snd_soc_tplg_hdr *hdr,
-		    void *bin, size_t size)
+int tplg_decode_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
+		    size_t pos ATTRIBUTE_UNUSED,
+		    struct snd_soc_tplg_hdr *hdr ATTRIBUTE_UNUSED,
+		    void *bin ATTRIBUTE_UNUSED,
+		    size_t size ATTRIBUTE_UNUSED)
 {
 	SNDERR("not implemented");
 	return -ENXIO;
 }
 
 /* decode cc from the binary input */
-int tplg_decode_cc(snd_tplg_t *tplg,
-		   size_t pos,
-		   struct snd_soc_tplg_hdr *hdr,
-		   void *bin, size_t size)
+int tplg_decode_cc(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
+		   size_t pos ATTRIBUTE_UNUSED,
+		   struct snd_soc_tplg_hdr *hdr ATTRIBUTE_UNUSED,
+		   void *bin ATTRIBUTE_UNUSED,
+		   size_t size ATTRIBUTE_UNUSED)
 {
 	SNDERR("not implemented");
 	return -ENXIO;
Signature · 1 line
2.16.4
Reviewed-by on the v1 series
#4 lore raw
In reply to Takashi Iwai

Dne 11. 05. 20 v 16:39 Takashi Iwai napsal(a):

Quoted 4 lines

Hi,

here is a few patches to shut up trivial compile warnings that have been introduced recently.

Thank you,
Jaroslav

Quoted 15 lines

Takashi

===

Takashi Iwai (3):
pcm: rate: Fix compile warning wrt bit ops and comparison
pcm: rate: Fix uninitialized variable warning
topology: Add missing ATTRIBUTE_UNUSED

  src/pcm/pcm_rate.c |  4 ++--
  src/topology/pcm.c | 18 ++++++++++--------
  2 files changed, 12 insertions(+), 10 deletions(-)
Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.