linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: au88x0: use explicitly signed char
@ 2022-10-24 16:29 Jason A. Donenfeld
  2022-10-24 21:11 ` Al Viro
  0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2022-10-24 16:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jason A. Donenfeld, Jaroslav Kysela, Takashi Iwai, alsa-devel

With char becoming unsigned by default, and with `char` alone being
ambiguous and based on architecture, signed chars need to be marked
explicitly as such. This fixes warnings like:

sound/pci/au88x0/au88x0_core.c:2029 vortex_adb_checkinout() warn: signedness bug returning '(-22)'
sound/pci/au88x0/au88x0_core.c:2046 vortex_adb_checkinout() warn: signedness bug returning '(-12)'
sound/pci/au88x0/au88x0_core.c:2125 vortex_adb_allocroute() warn: 'vortex_adb_checkinout(vortex, (0), en, 0)' is unsigned
sound/pci/au88x0/au88x0_core.c:2170 vortex_adb_allocroute() warn: 'vortex_adb_checkinout(vortex, stream->resources, en, 4)' is unsigned

As well, since one function returns errnos, return an `int` rather than
a `signed char`.

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 sound/pci/au88x0/au88x0.h      | 6 +++---
 sound/pci/au88x0/au88x0_core.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/pci/au88x0/au88x0.h b/sound/pci/au88x0/au88x0.h
index 0aa7af049b1b..6cbb2bc4a048 100644
--- a/sound/pci/au88x0/au88x0.h
+++ b/sound/pci/au88x0/au88x0.h
@@ -141,7 +141,7 @@ struct snd_vortex {
 #ifndef CHIP_AU8810
 	stream_t dma_wt[NR_WT];
 	wt_voice_t wt_voice[NR_WT];	/* WT register cache. */
-	char mixwt[(NR_WT / NR_WTPB) * 6];	/* WT mixin objects */
+	s8 mixwt[(NR_WT / NR_WTPB) * 6];	/* WT mixin objects */
 #endif
 
 	/* Global resources */
@@ -235,8 +235,8 @@ static int vortex_alsafmt_aspfmt(snd_pcm_format_t alsafmt, vortex_t *v);
 static void vortex_connect_default(vortex_t * vortex, int en);
 static int vortex_adb_allocroute(vortex_t * vortex, int dma, int nr_ch,
 				 int dir, int type, int subdev);
-static char vortex_adb_checkinout(vortex_t * vortex, int resmap[], int out,
-				  int restype);
+static int vortex_adb_checkinout(vortex_t * vortex, int resmap[], int out,
+				 int restype);
 #ifndef CHIP_AU8810
 static int vortex_wt_allocroute(vortex_t * vortex, int dma, int nr_ch);
 static void vortex_wt_connect(vortex_t * vortex, int en);
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index 2ed5100b8cae..f217c02dfdfa 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -1998,7 +1998,7 @@ static const int resnum[VORTEX_RESOURCE_LAST] =
  out: Mean checkout if != 0. Else mean Checkin resource.
  restype: Indicates type of resource to be checked in or out.
 */
-static char
+static int
 vortex_adb_checkinout(vortex_t * vortex, int resmap[], int out, int restype)
 {
 	int i, qty = resnum[restype], resinuse = 0;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: au88x0: use explicitly signed char
  2022-10-24 16:29 [PATCH] ALSA: au88x0: use explicitly signed char Jason A. Donenfeld
@ 2022-10-24 21:11 ` Al Viro
  2022-10-24 23:59   ` Jason A. Donenfeld
  0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2022-10-24 21:11 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: linux-kernel, Jaroslav Kysela, Takashi Iwai, alsa-devel

On Mon, Oct 24, 2022 at 06:29:29PM +0200, Jason A. Donenfeld wrote:
> With char becoming unsigned by default, and with `char` alone being
> ambiguous and based on architecture, signed chars need to be marked
> explicitly as such. This fixes warnings like:

It might make sparse to STFU, but it does *not* resolve the underlying
issue:

vortex_adb_checkinout() returns a number in range of 0..31 on success
and -ENOMEM on failure.  Quite a few callers don't bother to check...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: au88x0: use explicitly signed char
  2022-10-24 21:11 ` Al Viro
@ 2022-10-24 23:59   ` Jason A. Donenfeld
  2022-10-25  6:21     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2022-10-24 23:59 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel, Jaroslav Kysela, Takashi Iwai, alsa-devel

Hi Al,

On Mon, Oct 24, 2022 at 11:11 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> On Mon, Oct 24, 2022 at 06:29:29PM +0200, Jason A. Donenfeld wrote:
> > With char becoming unsigned by default, and with `char` alone being
> > ambiguous and based on architecture, signed chars need to be marked
> > explicitly as such. This fixes warnings like:
>
> It might make sparse to STFU, but it does *not* resolve the underlying
> issue:
>
> vortex_adb_checkinout() returns a number in range of 0..31 on success
> and -ENOMEM on failure.  Quite a few callers don't bother to check...

Yea, I saw that. I assume that the places that don't check don't
*need* to check. But maybe this driver is junk and other bugs lurk.
I'm not sure. Either way, I think this change is certainly an
improvement on the status quo. I don't intend to develop further on
it, but feel free to send patches atop once this lands.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: au88x0: use explicitly signed char
  2022-10-24 23:59   ` Jason A. Donenfeld
@ 2022-10-25  6:21     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-10-25  6:21 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: Al Viro, linux-kernel, Jaroslav Kysela, Takashi Iwai, alsa-devel

On Tue, 25 Oct 2022 01:59:50 +0200,
Jason A. Donenfeld wrote:
> 
> Hi Al,
> 
> On Mon, Oct 24, 2022 at 11:11 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > On Mon, Oct 24, 2022 at 06:29:29PM +0200, Jason A. Donenfeld wrote:
> > > With char becoming unsigned by default, and with `char` alone being
> > > ambiguous and based on architecture, signed chars need to be marked
> > > explicitly as such. This fixes warnings like:
> >
> > It might make sparse to STFU, but it does *not* resolve the underlying
> > issue:
> >
> > vortex_adb_checkinout() returns a number in range of 0..31 on success
> > and -ENOMEM on failure.  Quite a few callers don't bother to check...
> 
> Yea, I saw that. I assume that the places that don't check don't
> *need* to check. But maybe this driver is junk and other bugs lurk.
> I'm not sure. Either way, I think this change is certainly an
> improvement on the status quo. I don't intend to develop further on
> it, but feel free to send patches atop once this lands.

Yes, the driver is likely broken in some other way, too.
Such a corner case doesn't hit usually, and it's unlikely worth to
spend too much time on it.

In anyway, I applied the patch now to for-next branch.

Thanks!

Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-25  6:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 16:29 [PATCH] ALSA: au88x0: use explicitly signed char Jason A. Donenfeld
2022-10-24 21:11 ` Al Viro
2022-10-24 23:59   ` Jason A. Donenfeld
2022-10-25  6:21     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).