From 9d67f38062737d4aa0674f4d41f1942dfa993547 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 7 Apr 2024 13:28:07 +0800 Subject: [PATCH] canutils: Fix minor style issue found in canlib no functional change Signed-off-by: Xiang Xiao --- canutils/canlib/canlib_getbaud.c | 10 ++-------- canutils/canlib/canlib_getloopback.c | 13 +++---------- canutils/canlib/canlib_getsilent.c | 17 +++++------------ canutils/canlib/canlib_setbaud.c | 7 +------ canutils/canlib/canlib_setloopback.c | 8 +------- canutils/canlib/canlib_setsilent.c | 12 +++--------- include/canutils/canlib.h | 12 ++++++------ 7 files changed, 21 insertions(+), 58 deletions(-) diff --git a/canutils/canlib/canlib_getbaud.c b/canutils/canlib/canlib_getbaud.c index f8e2655c9..23965e70e 100644 --- a/canutils/canlib/canlib_getbaud.c +++ b/canutils/canlib/canlib_getbaud.c @@ -22,15 +22,10 @@ * Included Files ****************************************************************************/ -#include - #include - -#include -#include -#include #include #include + #include /**************************************************************************** @@ -63,10 +58,9 @@ int canlib_getbaud(int fd, FAR int *bauds) if (ret != OK) { canerr("CANIOC_GET_BITTIMING failed, errno=%d\n", errno); - return 0; + return ret; } *bauds = timings.bt_baud; - return ret; } diff --git a/canutils/canlib/canlib_getloopback.c b/canutils/canlib/canlib_getloopback.c index 5c13614ca..f9ba5fdf3 100644 --- a/canutils/canlib/canlib_getloopback.c +++ b/canutils/canlib/canlib_getloopback.c @@ -22,16 +22,10 @@ * Included Files ****************************************************************************/ -#include - #include - -#include -#include -#include -#include #include #include + #include /**************************************************************************** @@ -64,10 +58,9 @@ int canlib_getloopback(int fd, FAR bool *loopback) if (ret != OK) { canerr("CANIOC_GET_CONNMODES failed, errno=%d\n", errno); - return FALSE; + return ret; } - *loopback = (bool)connmodes.bm_loopback; - + *loopback = connmodes.bm_loopback; return ret; } diff --git a/canutils/canlib/canlib_getsilent.c b/canutils/canlib/canlib_getsilent.c index 10af602a4..ffb4abfed 100644 --- a/canutils/canlib/canlib_getsilent.c +++ b/canutils/canlib/canlib_getsilent.c @@ -22,16 +22,10 @@ * Included Files ****************************************************************************/ -#include - #include - -#include -#include -#include -#include #include #include + #include /**************************************************************************** @@ -45,8 +39,8 @@ * Wrapper for CANIOC_GET_CONNMODES. * * Input Parameter: - * fd - file descriptor of an opened can device - * loopback - pointer to a buffer to store the current silent mode state. + * fd - file descriptor of an opened can device + * silent - pointer to a buffer to store the current silent mode state. * * Returned Value: * Zero (OK) is returned on success. Otherwise -1 (ERROR) @@ -64,10 +58,9 @@ int canlib_getsilent(int fd, FAR bool *silent) if (ret != OK) { canerr("CANIOC_GET_CONNMODES failed, errno=%d\n", errno); - return FALSE; + return ret; } - *silent = (bool)connmodes.bm_silent; - + *silent = connmodes.bm_silent; return ret; } diff --git a/canutils/canlib/canlib_setbaud.c b/canutils/canlib/canlib_setbaud.c index c2e9c3086..0b4fa322a 100644 --- a/canutils/canlib/canlib_setbaud.c +++ b/canutils/canlib/canlib_setbaud.c @@ -22,15 +22,10 @@ * Included Files ****************************************************************************/ -#include - #include - -#include -#include -#include #include #include + #include /**************************************************************************** diff --git a/canutils/canlib/canlib_setloopback.c b/canutils/canlib/canlib_setloopback.c index f97cc792c..bc88956c8 100644 --- a/canutils/canlib/canlib_setloopback.c +++ b/canutils/canlib/canlib_setloopback.c @@ -22,16 +22,10 @@ * Included Files ****************************************************************************/ -#include - #include - -#include -#include -#include -#include #include #include + #include /**************************************************************************** diff --git a/canutils/canlib/canlib_setsilent.c b/canutils/canlib/canlib_setsilent.c index 5a1978571..da05f01b1 100644 --- a/canutils/canlib/canlib_setsilent.c +++ b/canutils/canlib/canlib_setsilent.c @@ -22,16 +22,10 @@ * Included Files ****************************************************************************/ -#include - #include - -#include -#include -#include -#include #include #include + #include /**************************************************************************** @@ -46,8 +40,8 @@ * peripheral never transmits on the bus, but receives all bus traffic. * * Input Parameter: - * fd - file descriptor of an opened can device - * loopback - whether to use loopback mode. + * fd - file descriptor of an opened can device + * silent - whether to use silent mode. * * Returned Value: * Zero (OK) is returned on success. Otherwise -1 (ERROR) diff --git a/include/canutils/canlib.h b/include/canutils/canlib.h index 75521b295..844107a3e 100644 --- a/include/canutils/canlib.h +++ b/include/canutils/canlib.h @@ -107,6 +107,8 @@ int canlib_getbaud(int fd, FAR int *bauds); * ****************************************************************************/ +int canlib_setloopback(int fd, bool loop); + /**************************************************************************** * Name: canlib_getloopback * @@ -124,8 +126,6 @@ int canlib_getbaud(int fd, FAR int *bauds); * ****************************************************************************/ -int canlib_setloopback(int fd, bool loop); - int canlib_getloopback(int fd, FAR bool *loop); /**************************************************************************** @@ -136,8 +136,8 @@ int canlib_getloopback(int fd, FAR bool *loop); * peripheral never transmits on the bus, but receives all bus traffic. * * Input Parameter: - * fd - file descriptor of an opened can device - * loopback - whether to use loopback mode. + * fd - file descriptor of an opened can device + * silent - whether to use silent mode. * * Returned Value: * Zero (OK) is returned on success. Otherwise -1 (ERROR) @@ -155,8 +155,8 @@ int canlib_setsilent(int fd, bool silent); * Wrapper for CANIOC_GET_CONNMODES. * * Input Parameter: - * fd - file descriptor of an opened can device - * loopback - pointer to a buffer to store the current silent mode state. + * fd - file descriptor of an opened can device + * silent - pointer to a buffer to store the current silent mode state. * * Returned Value: * Zero (OK) is returned on success. Otherwise -1 (ERROR)