You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2024/04/12 18:48:26 UTC
(nuttx-apps) branch master updated: canutils: Fix minor style issue found in canlib
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 9d67f3806 canutils: Fix minor style issue found in canlib
9d67f3806 is described below
commit 9d67f38062737d4aa0674f4d41f1942dfa993547
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Apr 7 13:28:07 2024 +0800
canutils: Fix minor style issue found in canlib
no functional change
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
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 <nuttx/config.h>
-
#include <sys/ioctl.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
#include <debug.h>
#include <errno.h>
+
#include <nuttx/can/can.h>
/****************************************************************************
@@ -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 <nuttx/config.h>
-
#include <sys/ioctl.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <fcntl.h>
#include <debug.h>
#include <errno.h>
+
#include <nuttx/can/can.h>
/****************************************************************************
@@ -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 <nuttx/config.h>
-
#include <sys/ioctl.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <fcntl.h>
#include <debug.h>
#include <errno.h>
+
#include <nuttx/can/can.h>
/****************************************************************************
@@ -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 <nuttx/config.h>
-
#include <sys/ioctl.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
#include <debug.h>
#include <errno.h>
+
#include <nuttx/can/can.h>
/****************************************************************************
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 <nuttx/config.h>
-
#include <sys/ioctl.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <fcntl.h>
#include <debug.h>
#include <errno.h>
+
#include <nuttx/can/can.h>
/****************************************************************************
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 <nuttx/config.h>
-
#include <sys/ioctl.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <fcntl.h>
#include <debug.h>
#include <errno.h>
+
#include <nuttx/can/can.h>
/****************************************************************************
@@ -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)