From 0676a1ba51784e2b44ce9100965e4554e13e48b9 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 22 Nov 2024 22:47:28 +0000 Subject: [PATCH] libpcm: fix buggy use of clip macro (evaluates its arg twice) --- sys/src/libpcm/conv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/src/libpcm/conv.c b/sys/src/libpcm/conv.c index b504a0aaa..98a2444d9 100644 --- a/sys/src/libpcm/conv.c +++ b/sys/src/libpcm/conv.c @@ -52,7 +52,15 @@ enum { #define MAXINT ((int)(~0UL>>1)) #define MININT (MAXINT+1) -#define clip(v) ((v) > MAXINT ? MAXINT : ((v) < MININT ? MININT : (v))) +static int +clip(vlong v) +{ + if(v > MAXINT) + return MAXINT; + if(v < MININT) + return MININT; + return v; +} static int chaninit(Chan *c, int irate, int orate, int count, uintptr caller)