Commit Graph

1146 Commits (1405a90e8b71cf0677d26eb78ed267d2500c15ff)

Author SHA1 Message Date
Marc Kleine-Budde 1405a90e8b j1939spy: main(): fix shift-count-overflow error
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)) {
|       |                                    ^~
2024-05-29 14:30:05 +02:00
Marc Kleine-Budde e0bb44c908 isobusfs_cmn: isobusfs_print_timestamp(): always use 64-bit for time stamp formatting
Using C99 `unsigned long long` to format `struct timeval`'s `tv_sec`
and `tv_usec`, fix incorrect print under some 32bit platform which
using time64.
2024-05-29 14:27:34 +02:00
Marc Kleine-Budde c468568f1e
Merge pull request #540 from olerem/isobusfs_cmn_warning
isobusfs: address snprintf truncation warning with explicit limits
2024-05-29 11:17:57 +02:00
Oleksij Rempel 8012b3b23d isobusfs: address snprintf truncation warning with explicit limits
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>
2024-05-29 10:54:18 +02:00
Marc Kleine-Budde a7ff280c62
Merge pull request #537 from marckleinebudde/bcmserver-fix-warning-better
bcmserver: use pragma to silence unknown pragma option
2024-05-28 12:12:17 +02:00
Marc Kleine-Budde c98e25334b bcmserver: use pragma to silence unknown pragma option
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"
|       |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-05-28 12:03:15 +02:00
Marc Kleine-Budde c2e40edd24
Merge pull request #517 from marckleinebudde/bcmserver-fix-warning
bcmserver: use pragma to silence gnu-variable-sized-type-not-at-end warning
2024-05-28 11:39:43 +02:00
Marc Kleine-Budde f12a59d780
Merge pull request #534 from yegorich/cmake-format
CMake: resolve linting issues
2024-05-27 12:26:59 +02:00
Yegor Yefremov fbd097edf6 CMake: resolve linting issues
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>
2024-05-27 11:48:25 +02:00
Marc Kleine-Budde 465ee7c203
Merge pull request #533 from yegorich/editorconfig
Add configuration file for EditorConfig
2024-05-26 22:29:27 +02:00
Yegor Yefremov 800c48fb1e Add configuration file for EditorConfig
Handles source and CMake files.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2024-05-26 17:42:43 +02:00
Marc Kleine-Budde e865e54490 bcmserver: use pragma to silence gnu-variable-sized-type-not-at-end warning
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;
|                                ^
2024-05-26 16:57:25 +02:00
Marc Kleine-Budde 4d16dc867d bcmserver: remove trailing whitespace 2024-05-26 16:57:25 +02:00
Marc Kleine-Budde 6c893e5c4f
Merge pull request #531 from yegorich/ignore-tags
Ignore ctags generated tags file
2024-05-26 16:26:08 +02:00
Marc Kleine-Budde 7b6daa3aca
Merge pull request #532 from yegorich/cmake-fixes
Cmake fixes
2024-05-26 16:23:31 +02:00
Yegor Yefremov 0e4c2d35f2 CMakeLists.txt: print the detected CMake version
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2024-05-26 15:22:37 +02:00
Yegor Yefremov 3b5593f499 CMakeLists.txt: bump the minimum required version to 3.5
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>
2024-05-26 15:20:45 +02:00
Yegor Yefremov 2a93b10057 Ignore ctags generated tags file
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2024-05-26 12:51:33 +02:00
Marc Kleine-Budde b76bb3f66c
Merge pull request #530 from olerem/isobusfs-fixes
Isobusfs fixes
2024-05-25 19:23:53 +02:00
Oleksij Rempel 06ab86226a isobusfs_srv_cm: do not try to add padding beyond the buffer
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>
2024-05-25 07:57:16 +02:00
Oleksij Rempel fc742c574e isobusfs_srv_cm: make sure we do le16toh/htole16 conversation for name_len
name_len is __le16. We need always convert it to host byte order.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
2024-05-25 07:57:16 +02:00
Oleksij Rempel 1e8bc8fd34 isobusfs: do not kill application on error_queue error
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>
2024-05-25 07:57:16 +02:00
Marc Kleine-Budde d05810f5fe
Merge pull request #522 from SECloudUNIMORE/pr-usage
Refactor the help/usage message for canplayer
2024-05-15 15:26:36 +02:00
GZZ8 23648c8a31
Refactor the help/usage message for canplayer
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>
2024-05-14 19:19:35 +02:00
Marc Kleine-Budde 185c14f464
Merge pull request #519 from marckleinebudde/can-calc-bit-timing-fix-option-parsing
can-calc-bit-timing: in case of invalid option exit with error
2024-05-07 15:34:31 +02:00
Marc Kleine-Budde 4a9c00539b can-calc-bit-timing: in case of invalid option exit with error
Link: https://github.com/linux-can/can-utils/issues/518
Reported-by: https://github.com/EnricoMontecaggi
Fixes: f4a9e5b57d ("can-calc-bit-timing.c: Reformat help/usage output to be compatible with help2man.")
2024-05-07 15:21:39 +02:00
Oliver Hartkopp 8d7d7650d4
can-utils: fix sign-compare warnings (#513)
Fixing several build issues reported by Gary Bisson when he was building
can-utils with clang (AOSP14).

URL: https://github.com/linux-can/can-utils/pull/512
Reported-by: Gary Bisson (https://github.com/gibsson)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-04-24 20:02:02 +02:00
Marc Kleine-Budde 30a46d72bd
Merge pull request #510 from olerem/clang-fixes
isobusfs: fix clang warnings
2024-03-22 11:09:11 +01:00
Oleksij Rempel 91a93353ae isobusfs: fix clang warnings
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>
2024-03-22 10:44:17 +01:00
Marc Kleine-Budde bbd48cb150
Merge pull request #509 from marckleinebudde/mcp251xfd-regmap-fix-compiler-warning
mcp251xfd-regmap: do_mcp251xfd_regmap_read(): fix compiler warning in a more straight forward way
2024-03-19 13:05:06 +01:00
Marc Kleine-Budde 95f12594a6 mcp251xfd-regmap: do_mcp251xfd_regmap_read(): fix compiler warning in a more straight forward way
Link: d294cd928c (r139957294)
Suggested-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-19 13:01:46 +01:00
Marc Kleine-Budde 8c94f3f72a
Merge pull request #508 from marckleinebudde/mcp251xfd-regmap-fix-compiler-warning
mcp251xfd-regmap: fix compiler warning
2024-03-19 11:45:32 +01:00
Marc Kleine-Budde d294cd928c mcp251xfd-regmap: fix compiler warning
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
2024-03-19 09:30:59 +01:00
Oliver Hartkopp 001b230b10 cangen: initialize reserved struct CAN(FD) frame elements
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>
2024-03-18 12:35:29 +01:00
Oliver Hartkopp 6d47f5c22b
Merge pull request #504 from hartkopp/master
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
2024-03-13 22:03:02 +01:00
Oliver Hartkopp dd16f2603b can-utils: make local functions static
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-12 20:10:00 +01:00
Oliver Hartkopp 8535b1d217 log2asc: print error message if no valid CAN CC/FD frame is received
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-12 19:38:04 +01:00
Oliver Hartkopp 27030b3e54 lib: make sprint_canframe the buffer size aware snprintf_canframe
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>
2024-03-12 19:11:58 +01:00
Oliver Hartkopp 8e131401c1 lib: remove obsolete brackets
From review feedback.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-06 12:10:32 +01:00
Oliver Hartkopp 7905b632ff canlogserver: unify curly brackets in if statements
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-06 12:01:39 +01:00
Oliver Hartkopp 6f7b146166 cangen: unify curly brackets and apply review feedback
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-06 11:57:54 +01:00
Oliver Hartkopp 09aa4d55bf asc2log: unify curly brackets at function definition
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>
2024-03-06 11:42:13 +01:00
Oliver Hartkopp 87a3058019 cangen: support generation features for CAN XL specific content
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-04 22:50:52 +01:00
SCZeiDan 64dc0b2169
Update testj1939.c, correct verbose information. (#503)
Modify the verbose information for setting the promiscuous mode option;
2024-03-04 14:54:41 +01:00
Oliver Hartkopp 443312d6ce cangen: add initial CAN XL support
TODO:
- Test all features
- make CAN XL content variable

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-03 21:29:49 +01:00
Oliver Hartkopp 09b8a6431f cangen: add missing long CAN frame view for len8_dlc and eff
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-02 22:36:49 +01:00
Oliver Hartkopp 9a21de13f8 cangen: convert to CAN frame unit type
As preparation for CAN XL support.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-02 22:36:36 +01:00
Oliver Hartkopp 2af5e6aaaa canlogserver/log2long: make CAN XL ASCII buffer static
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-01 15:56:21 +01:00
Oliver Hartkopp 740c0ba156 lib/cansend: update documentation for CAN XL frame format
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-29 09:54:47 +01:00
Oliver Hartkopp 7761d8bcf8 canlogserver: add CAN XL support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-29 08:44:27 +01:00