mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									a7f2ef6d34
								
							
						
					
					
						commit
						0d9beb5b2e
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -34,7 +34,10 @@ static bool match_ids(RTLIL::IdString id, std::string pattern)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (id == pattern)
 | 
						if (id == pattern)
 | 
				
			||||||
		return true;
 | 
							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;
 | 
							return true;
 | 
				
			||||||
	if (patmatch(pattern.c_str(), id.c_str()))
 | 
						if (patmatch(pattern.c_str(), id.c_str()))
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue