libpci: ecam: Fix discards const from pointer target
Subsystems (2)
PATCH 1/2 libpci: ecam: Fix discards const from pointer target
endptr is used as the return from strchr(addrs, ',') which is a const char. endptr is subsequently used as a pointer to the token which is char. Fix by not reusing endptr, but declare addrsptr as a const char * pointer for use in the first case addressing the warning.
fixes:
ecam.c: In function 'parse_next_addrs':
ecam.c:620:10: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
620 | endptr = strchr(addrs, ',');
| ^
--- lib/ecam.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
lib/ecam.c +5 -5
@@ -603,7 +603,7 @@ static int parse_next_addrs(const char *addrs, const char **next, int *domain, u8 *start_bus, u8 *end_bus, u64 *addr, u32 *length) { u64 ullnum; -const char *sep1, *sep2; +const char *addrsptr, *sep1, *sep2;int addr_len;char *endptr;long num;
@@ -617,14 +617,14 @@ parse_next_addrs(const char *addrs, const char **next, int *domain, u8 *start_bureturn 0 ; } - endptr =strchr (addrs,',' ); -if (endptr) - addr_len = endptr - addrs; + addrsptr =strchr (addrs,',' ); +if (addrsptr) + addr_len = addrsptr - addrs;else addr_len =strlen (addrs);if (next) - *next = endptr ? (endptr+1 ) :NULL ; + *next = addrsptr ? (addrsptr+1 ) :NULL ; sep1 =memchr (addrs,':' , addr_len);if (!sep1)
Signature · 1 line
2.51.0
Hi!
Quoted 4 lines
endptr is used as the return from
strchr(addrs, ',')which is a const char. endptr is subsequently used as a pointer to the token which is char. Fix by not reusing endptr, but declare addrsptr as a const char * pointer for use in the first case addressing the warning.
[...]
Thanks, both patches applied.
Have a nice day
Signature · 2 lines
Martin `MJ' Mareš <[email protected]> http://mj.ucw.cz/ United Computer Wizards, Prague, Czech Republic, Europe, Earth, Universe