mirror of
https://github.com/linux-can/can-utils.git
synced 2026-09-22 08:06:34 +02:00
lib: add pr_debug() macro
Add the pr_debug() macro so that:
#ifdef DEBUG
printf("foo");
#endif
can be replaced by:
pr_debug("foo");
Apply the pr_debug() macro wherever relevant.
Currently, there is no consensus whether debug messages should be
printed on stdout or stderr. Most of the modules: canbusload.c,
candump.c and canlogserver.c use stdout but
mcp251xfd/mcp251xfd-dev-coredump.c uses stderr. Harmonize the behavior
by following the major trend and make
mcp251xfd/mcp251xfd-dev-coredump.c also output to stdout.
slcanpty.c does a #define DEBUG, meaning that debug is always turned
on for this file. Remove this and make debug an option like every
other files.
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/all/20221114163848.3398-5-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
21fb43532e
commit
0cfd56d613
+3
-6
@@ -61,6 +61,7 @@
|
||||
#include <linux/can.h>
|
||||
#include <linux/can/raw.h>
|
||||
|
||||
#include "lib.h"
|
||||
#include "terminal.h"
|
||||
#include "canframelen.h"
|
||||
|
||||
@@ -310,9 +311,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("open %d '%s'.\n", i, ptr);
|
||||
#endif
|
||||
pr_debug("open %d '%s'.\n", i, ptr);
|
||||
|
||||
s[i] = socket(PF_CAN, SOCK_RAW, CAN_RAW);
|
||||
if (s[i] < 0) {
|
||||
@@ -358,10 +357,8 @@ int main(int argc, char **argv)
|
||||
if (nbytes > max_bitrate_len)
|
||||
max_bitrate_len = nbytes; /* for nice printing */
|
||||
|
||||
pr_debug("using interface name '%s'.\n", ifr.ifr_name);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("using interface name '%s'.\n", ifr.ifr_name);
|
||||
#endif
|
||||
/* try to switch the socket into CAN FD mode */
|
||||
const int canfd_on = 1;
|
||||
setsockopt(s[i], SOL_CAN_RAW, CAN_RAW_FD_FRAMES, &canfd_on, sizeof(canfd_on));
|
||||
|
||||
Reference in New Issue
Block a user