[alsa-devel] [PATCH 2/3] topology/builder: Fix absolute value warning

Rosen Penev rosenp at gmail.com
Tue Dec 10 10:10:46 CET 2019


next_hdr_pos is unsigned and promotes offset as such. This makes
the abs call useless.

Changed the abs call to labs and the offset to off_t to avoid this.

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 src/topology/builder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/topology/builder.c b/src/topology/builder.c
index 3adbad45..98956dac 100644
--- a/src/topology/builder.c
+++ b/src/topology/builder.c
@@ -45,7 +45,7 @@ static int write_block_header(snd_tplg_t *tplg, unsigned int type,
 {
 	struct snd_soc_tplg_hdr hdr;
 	size_t bytes;
-	int offset = lseek(tplg->out_fd, 0, SEEK_CUR);
+	off_t offset = lseek(tplg->out_fd, 0, SEEK_CUR);
 
 	memset(&hdr, 0, sizeof(hdr));
 	hdr.magic = SND_SOC_TPLG_MAGIC;
@@ -64,7 +64,7 @@ static int write_block_header(snd_tplg_t *tplg, unsigned int type,
 			" offset 0x%x is %s by %d bytes\n",
 			tplg->next_hdr_pos, offset,
 			(unsigned int)offset > tplg->next_hdr_pos ? "ahead" : "behind",
-			abs(offset - tplg->next_hdr_pos));
+			labs(offset - (off_t)tplg->next_hdr_pos));
 		exit(-EINVAL);
 	}
 
-- 
2.23.0



More information about the Alsa-devel mailing list