[PATCH] v4l2-tracer: check for strerrorname_np()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The v4l2-tracer converts the errno integer to a string using
strerrorname_np().  Check if this function is available and,
if not, use strerror() instead.

Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
---
 configure.ac                           | 2 ++
 utils/v4l2-tracer/libv4l2tracer.cpp    | 6 +++---
 utils/v4l2-tracer/trace.cpp            | 2 +-
 utils/v4l2-tracer/v4l2-tracer-common.h | 6 ++++++
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2b26e3dd..dc9c4af7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -323,6 +323,8 @@ if test "x$jsonc_pkgconfig" = "xno"; then
     AC_MSG_WARN(json-c $JSONC_VERSION_REQUIRED or higher required for v4l2-tracer)
 fi
 
+AC_CHECK_FUNCS([strerrorname_np], AC_DEFINE([HAVE_STRERRORNAME_NP],[1],[glibc has function strerrorname_np]))
+
 # Check for pthread
 
 AS_IF([test x$enable_shared != xno],
diff --git a/utils/v4l2-tracer/libv4l2tracer.cpp b/utils/v4l2-tracer/libv4l2tracer.cpp
index 090a43d7..6b438628 100644
--- a/utils/v4l2-tracer/libv4l2tracer.cpp
+++ b/utils/v4l2-tracer/libv4l2tracer.cpp
@@ -201,7 +201,7 @@ int munmap(void *start, size_t length)
 	json_object *munmap_obj = json_object_new_object();
 
 	if (errno)
-		json_object_object_add(munmap_obj, "errno", json_object_new_string(strerrorname_np(errno)));
+		json_object_object_add(munmap_obj, "errno", json_object_new_string(STRERR(errno)));
 
 	json_object *munmap_args = json_object_new_object();
 	json_object_object_add(munmap_args, "start", json_object_new_int64((int64_t)start));
@@ -242,7 +242,7 @@ int ioctl(int fd, unsigned long cmd, ...)
 		int ret = (*original_ioctl)(fd, cmd, arg);
 		if (errno)
 			json_object_object_add(ioctl_obj, "errno",
-			                       json_object_new_string(strerrorname_np(errno)));
+			                       json_object_new_string(STRERR(errno)));
 		write_json_object_to_json_file(ioctl_obj);
 		json_object_put(ioctl_obj);
 		return ret;
@@ -270,7 +270,7 @@ int ioctl(int fd, unsigned long cmd, ...)
 	int ret = (*original_ioctl)(fd, cmd, arg);
 
 	if (errno)
-		json_object_object_add(ioctl_obj, "errno", json_object_new_string(strerrorname_np(errno)));
+		json_object_object_add(ioctl_obj, "errno", json_object_new_string(STRERR(errno)));
 
 	/* Trace driver arguments if userspace will be reading them i.e. _IOR or _IOWR ioctls */
 	if ((cmd & IOC_OUT) != 0U) {
diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp
index d5a09ad7..4896751b 100644
--- a/utils/v4l2-tracer/trace.cpp
+++ b/utils/v4l2-tracer/trace.cpp
@@ -71,7 +71,7 @@ void trace_mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t o
 	json_object *mmap_obj = json_object_new_object();
 
 	if (errno)
-		json_object_object_add(mmap_obj, "errno", json_object_new_string(strerrorname_np(errno)));
+		json_object_object_add(mmap_obj, "errno", json_object_new_string(STRERR(errno)));
 
 	json_object *mmap_args = json_object_new_object();
 	json_object_object_add(mmap_args, "addr", json_object_new_int64((int64_t)addr));
diff --git a/utils/v4l2-tracer/v4l2-tracer-common.h b/utils/v4l2-tracer/v4l2-tracer-common.h
index 362a7ba6..0bdb125d 100644
--- a/utils/v4l2-tracer/v4l2-tracer-common.h
+++ b/utils/v4l2-tracer/v4l2-tracer-common.h
@@ -34,6 +34,12 @@
 #define STR(x) #x
 #define STRING(x) STR(x)
 
+#ifdef HAVE_STRERRORNAME_NP
+#define STRERR(x) strerrorname_np(x)
+#else
+#define STRERR(x) strerror(x)
+#endif
+
 struct val_def {
 	long val;
 	const char *str;
-- 
2.38.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux