Skip to content

mcp251xfd: mcp251xfd_regmap_read(): don't assign return value of strchr() to char *#620

Merged
marckleinebudde merged 1 commit intolinux-can:masterfrom
marckleinebudde:mcp251xfd-fix-strchr
Mar 4, 2026
Merged

mcp251xfd: mcp251xfd_regmap_read(): don't assign return value of strchr() to char *#620
marckleinebudde merged 1 commit intolinux-can:masterfrom
marckleinebudde:mcp251xfd-fix-strchr

Conversation

@marckleinebudde
Copy link
Member

The file_path of strchr(file_path, '/') is a const char *. In this case the strchr() in debian experimental returns a const char *, leading to this error message:

mcp251xfd/mcp251xfd-regmap.c:75:13: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
   75 |         tmp = strchr(file_path, '/');
      |             ^

Fix the error by using the return value from strchr() directly in the if().

Link: https://github.com/linux-can/can-utils/actions/runs/22649777324/job/65679726209?pr=619

…hr() to `char *`

The `file_path` of `strchr(file_path, '/')` is a `const char *`. In this
case the `strchr()` in debian experimental returns a `const char *`,
leading to this error message:

```
mcp251xfd/mcp251xfd-regmap.c:75:13: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
   75 |         tmp = strchr(file_path, '/');
      |             ^
```

Fix the error by using the return value from `strchr()` directly in the
`if()`.

Link: https://github.com/linux-can/can-utils/actions/runs/22649777324/job/65679726209?pr=619
@marckleinebudde marckleinebudde changed the title mcp251xfd: mcp251xfd_regmap_read(): don't assign return value of strchr() to char * mcp251xfd: mcp251xfd_regmap_read(): don't assign return value of strchr() to char * Mar 4, 2026
@marckleinebudde marckleinebudde merged commit 1520ab5 into linux-can:master Mar 4, 2026
12 checks passed
@marckleinebudde marckleinebudde deleted the mcp251xfd-fix-strchr branch March 4, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant