From: mwilck@suse.com
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@redhat.com, Xose Vazquez Perez <xose.vazquez@gmail.com>,
Martin Wilck <mwilck@suse.com>
Subject: [dm-devel] [PATCH 4/4] libmultipath: fix compilation error with gcc 10 on i386
Date: Fri, 12 Feb 2021 00:46:50 +0100 [thread overview]
Message-ID: <20210211234650.21890-4-mwilck@suse.com> (raw)
In-Reply-To: <20210211234650.21890-1-mwilck@suse.com>
From: Martin Wilck <mwilck@suse.com>
gcc complained about a possible negative value of "nr" in the
memcpy() call. I consider that a false positive, but it's easily
fixed.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
libmultipath/sysfs.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index 5390de6..7a2af1e 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -344,24 +344,23 @@ bool sysfs_is_multipathed(struct path *pp, bool set_wwid)
pthread_cleanup_push(close_fd, (void *)fd);
nr = read(fd, uuid, sizeof(uuid));
if (nr > (int)UUID_PREFIX_LEN &&
- !memcmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN))
+ !memcmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN)) {
found = true;
- else if (nr < 0) {
+ if (set_wwid) {
+ nr -= UUID_PREFIX_LEN;
+ memcpy(pp->wwid, uuid + UUID_PREFIX_LEN, nr);
+ if (nr == WWID_SIZE) {
+ condlog(4, "%s: overflow while reading from %s",
+ __func__, pathbuf);
+ pp->wwid[0] = '\0';
+ } else {
+ pp->wwid[nr] = '\0';
+ strchop(pp->wwid);
+ }
+ }
+ } else if (nr < 0)
condlog(1, "%s: error reading from %s: %m",
__func__, pathbuf);
- }
- if (found && set_wwid) {
- nr -= UUID_PREFIX_LEN;
- memcpy(pp->wwid, uuid + UUID_PREFIX_LEN, nr);
- if (nr == WWID_SIZE) {
- condlog(4, "%s: overflow while reading from %s",
- __func__, pathbuf);
- pp->wwid[0] = '\0';
- } else {
- pp->wwid[nr] = '\0';
- strchop(pp->wwid);
- }
- }
pthread_cleanup_pop(1);
}
--
2.29.2
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2021-02-11 23:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 23:46 [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity mwilck
2021-02-11 23:46 ` [dm-devel] [PATCH 2/4] multipath-tools: devt test: avoid failure when run in containers mwilck
2021-02-11 23:46 ` [dm-devel] [PATCH 3/4] multipath-tools: fix compilation errors on 32-bit musl mwilck
2021-02-11 23:46 ` mwilck [this message]
2021-02-15 21:39 ` [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity Benjamin Marzinski
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=20210211234650.21890-4-mwilck@suse.com \
--to=mwilck@suse.com \
--cc=bmarzins@redhat.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
--cc=xose.vazquez@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).