Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: alsa-devel@alsa-project.org
Subject: [alsa-devel] [PATCH 2/3] topology/builder: Fix absolute value warning
Date: Tue, 10 Dec 2019 01:10:46 -0800	[thread overview]
Message-ID: <20191210091047.143081-2-rosenp@gmail.com> (raw)
In-Reply-To: <20191210091047.143081-1-rosenp@gmail.com>

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@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

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2019-12-10  9:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-10  9:10 [alsa-devel] [PATCH 1/3] treewide: Fix -Wformat=2 warnings Rosen Penev
2019-12-10  9:10 ` Rosen Penev [this message]
2019-12-10  9:10 ` [alsa-devel] [PATCH 3/3] treewide: Remove extra ; warning Rosen Penev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191210091047.143081-2-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox