Fix the following error, by converting recvflags into a 64 bit type.
| /home/j1939spy.c: In function 'main':
| /home/j1939spy.c:248:36: error: left shift count >= width of type [-Werror=shift-count-overflow]
| 248 | if (recvflags & (1 << SCM_TIMESTAMP)) {
| | ^~
Modify the isobusfs_log function in isobusfs_cmn.c to explicitly limit
the lengths of the time_buffer, level_str, and log_entry strings in
the snprintf format string to 40, 10, and 150 characters respectively.
This change acknowledges that truncation may still occur, but it is now
explicit and controlled.
This change silences the following warning:
cmake -DCMAKE_BUILD_TYPE=Debug -D CMAKE_C_COMPILER=gcc -B build
cmake --build build
/home/isobusfs/isobusfs_cmn.c: In function 'isobusfs_log':
/home/isobusfs/isobusfs_cmn.c:104:30: warning: '%s' directive output
may be truncated writing up to 191 bytes into a region of size between
182 and 245 [-Wformat-truncation=]
104 | "[%s] [%s]: %s", time_buffer, level_str, log_entry);
| ^~ ~~~~~~~~~
/home/isobusfs/isobusfs_cmn.c:103:9: note: 'snprintf' output 12 or more
bytes (assuming 266) into a destination of size 256
103 | snprintf(complete_log_entry, sizeof(complete_log_entry),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104 | "[%s] [%s]: %s", time_buffer, level_str, log_entry);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Silence the following warning by switching it of via a pragma.
| bcmserver.c: In function 'main':
| bcmserver.c:159:32: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
| 159 | #pragma GCC diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Improve indentation according to the .editorconfig style.
Write commands in lowercase letters.
Break long lines.
Remove double keywords (PRIVATE).
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Silence the following warning by switching it of via a pragma.
| bcmserver.c:159:23: warning: field 'msg_head' with variable sized
| type 'struct bcm_msg_head' not at the end of a struct or class is a
| GNU extension [-Wgnu-variable-sized-type-not-at-end]
| struct bcm_msg_head msg_head;
| ^
CMake versions prior to 3.5 are regarded as deprecated and will cause
an error on recent CMake versions.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
The memset in isobusfs_srv_volume_status_resp() was attempting to make a
padding beyond the buffer. Fix it.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Kernel may notify us about some error, which may happens if the bus was
in the error state. But this is not a good reason to kill application,
especially the server side.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Limit the error return value only to unknown options.
If the utility is invoked with the help option '-h',
display the usage message and exit successfully.
Co-authored-by: Filip Valgimigli <filip.valgimigli@unimore.it>
Signed-off-by: Filip Valgimigli <filip.valgimigli@unimore.it>
Fix following clang warnings:
CC isobusfs/isobusfs_srv_fa.o
isobusfs/isobusfs_srv_fa.c:387:6: warning: variable 'handle' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (ret < 0) {
^~~~~~~
isobusfs/isobusfs_srv_fa.c:411:15: note: uninitialized use occurs here
res.handle = handle;
^~~~~~
isobusfs/isobusfs_srv_fa.c:387:2: note: remove the 'if' if its condition is
always false
if (ret < 0) {
^~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:368:6: warning: variable 'handle' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (name_len > ISOBUSFS_MAX_PATH_NAME_LENGTH) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:411:15: note: uninitialized use occurs here
res.handle = handle;
^~~~~~
isobusfs/isobusfs_srv_fa.c:368:2: note: remove the 'if' if its condition is
always false
if (name_len > ISOBUSFS_MAX_PATH_NAME_LENGTH) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:362:6: warning: variable 'handle' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (name_len > msg->len - sizeof(*req)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:411:15: note: uninitialized use occurs here
res.handle = handle;
^~~~~~
isobusfs/isobusfs_srv_fa.c:362:2: note: remove the 'if' if its condition is
always false
if (name_len > msg->len - sizeof(*req)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:356:6: warning: variable 'handle' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!client) {
^~~~~~~
isobusfs/isobusfs_srv_fa.c:411:15: note: uninitialized use occurs here
res.handle = handle;
^~~~~~
isobusfs/isobusfs_srv_fa.c:356:2: note: remove the 'if' if its condition is
always false
if (!client) {
^~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:352:16: note: initialize the variable 'handle' to
silence this warning
uint8_t handle;
^
= '\0'
isobusfs/isobusfs_srv_fa.c:505:9: warning: variable 'entry_count' set but not
used [-Wunused-but-set-variable]
size_t entry_count = 0;
^
5 warnings generated.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Fix the following compiler warning:
| mcp251xfd/mcp251xfd-regmap.c:38:4: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
| fscanf(reg_file, "%*[^\n]\n");
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~
Reported-by: https://github.com/Chaitanya84
Link: https://github.com/linux-can/can-utils/pull/506
With 'cansend' and other tools the reserved elements are set to zero.
Fix this missing initialization in 'cangen'.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
can-utils: support CAN XL
This patch set adds support for CAN XL including VCIDs (Linux v6.9+)
Tools that completely support CAN XL:
candump
cangen
canlogserver
canplayer
cansend
log2long
CC/FD-only tools that have been adapted to the lib.[ch] changes:
log2asc
asc2log
Main changes:
lib/cangen: add documentation for CAN XL ASCII representation
lib: remove separate maxdlen parameter as every needed info is part of the CAN frame now
lib: remove fprint functions and only support sprint
lib: rework for static single buffer to contain a complete ASCII CAN XL frame
lib: introduce a CAN frame unit type to contain CAN CC/FD/XL frames in one union
canplayer/log2asc/log2long: make sscanf() buffer length aware
cangen: fix views for some features for long CAN frame output
general cleanups and buffer overflow safety measures
Make sure the library functions to convert CAN frames into ASCII
represenation do not exceed the given buffer size. This also applies
to the long CAN frame output library function.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Move the curly brackets to the start of the next line to follow the
common coding style in can-utils.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>