mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	cppcheck: (warning) Possible null pointer dereference: nvh
Move the 'nvh = (void *)buf' assignment after the 'buf == NULL' check to resolve the warning. Interestingly, cppcheck 1.88 correctly determines that the existing code is safe, while cppcheck 1.86 reports the warning. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #9732
This commit is contained in:
		
							parent
							
								
									180c41e0b7
								
							
						
					
					
						commit
						9791683901
					
				@ -2558,7 +2558,7 @@ nvlist_common(nvlist_t *nvl, char *buf, size_t *buflen, int encoding,
 | 
			
		||||
#else
 | 
			
		||||
	int host_endian = 0;
 | 
			
		||||
#endif	/* _LITTLE_ENDIAN */
 | 
			
		||||
	nvs_header_t *nvh = (void *)buf;
 | 
			
		||||
	nvs_header_t *nvh;
 | 
			
		||||
 | 
			
		||||
	if (buflen == NULL || nvl == NULL ||
 | 
			
		||||
	    (nvs.nvs_priv = (nvpriv_t *)(uintptr_t)nvl->nvl_priv) == NULL)
 | 
			
		||||
@ -2577,6 +2577,7 @@ nvlist_common(nvlist_t *nvl, char *buf, size_t *buflen, int encoding,
 | 
			
		||||
		if (buf == NULL || *buflen < sizeof (nvs_header_t))
 | 
			
		||||
			return (EINVAL);
 | 
			
		||||
 | 
			
		||||
		nvh = (void *)buf;
 | 
			
		||||
		nvh->nvh_encoding = encoding;
 | 
			
		||||
		nvh->nvh_endian = nvl_endian = host_endian;
 | 
			
		||||
		nvh->nvh_reserved1 = 0;
 | 
			
		||||
@ -2588,6 +2589,7 @@ nvlist_common(nvlist_t *nvl, char *buf, size_t *buflen, int encoding,
 | 
			
		||||
			return (EINVAL);
 | 
			
		||||
 | 
			
		||||
		/* get method of encoding from first byte */
 | 
			
		||||
		nvh = (void *)buf;
 | 
			
		||||
		encoding = nvh->nvh_encoding;
 | 
			
		||||
		nvl_endian = nvh->nvh_endian;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user