aboutsummaryrefslogtreecommitdiffstats
path: root/passes
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@gmail.com>2020-05-27 09:33:49 +0100
committerRupert Swarbrick <rswarbrick@gmail.com>2020-05-27 09:34:15 +0100
commit0d9beb5b2eec3ba839faa58a1a775311d9c3376c (patch)
tree8d927a947f50a04d27c114550b78b623707a6c8c /passes
parenta7f2ef6d34c4b336a910b3c6f3d2cc11da8a82b4 (diff)
downloadyosys-0d9beb5b2eec3ba839faa58a1a775311d9c3376c.tar.gz
yosys-0d9beb5b2eec3ba839faa58a1a775311d9c3376c.tar.bz2
yosys-0d9beb5b2eec3ba839faa58a1a775311d9c3376c.zip
Silence warning in select.cc
With GCC 9.3, at least, compiling select.cc spits out a warning about an implausible bound being passed to strncmp. This comes from inlining IdString::compare(): it turns out that passing std::string::npos as a bound to strncmp triggers it. This patch replaces the compare call with a memcmp with the same effect. The repeated calls to IdString::c_str are slightly inefficient, but I'll address that in a follow-up commit.
Diffstat (limited to 'passes')
-rw-r--r--passes/cmds/select.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/passes/cmds/select.cc b/passes/cmds/select.cc
index 6e728c16f..c5ef72b1c 100644
--- a/passes/cmds/select.cc
+++ b/passes/cmds/select.cc
@@ -34,7 +34,10 @@ static bool match_ids(RTLIL::IdString id, std::string pattern)
{
if (id == pattern)
return true;
- if (id.size() > 0 && id[0] == '\\' && id.compare(1, std::string::npos, pattern.c_str()) == 0)
+ const char *id_c = id.c_str();
+ if (*id_c == '\\' &&
+ id.size() == 1 + pattern.size() &&
+ memcmp(id_c + 1, pattern.c_str(), pattern.size()) == 0)
return true;
if (patmatch(pattern.c_str(), id.c_str()))
return true;