Skip to contentSkip to conversation

v4l2-tracer: use __FILE_NAME__ if available

PATCH In review Deborah Brouwer 2 participants 2 messages Mar 31, 2023 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v4l2-tracer: use __FILE_NAME__ if available

Use __FILE_NAME__ if available to avoid printing the entire relative path in verbose and debug messages, otherwise fall back to __FILE__.

---
 utils/v4l2-tracer/libv4l2tracer.cpp      | 12 +++---
 utils/v4l2-tracer/retrace-helper.cpp     | 16 ++++----
 utils/v4l2-tracer/retrace.cpp            | 52 ++++++++++++------------
 utils/v4l2-tracer/trace-helper.cpp       | 18 ++++----
 utils/v4l2-tracer/trace.cpp              |  4 +-
 utils/v4l2-tracer/v4l2-tracer-common.cpp |  4 +-
 utils/v4l2-tracer/v4l2-tracer-common.h   |  6 +++
 utils/v4l2-tracer/v4l2-tracer.cpp        | 28 ++++++-------
 8 files changed, 73 insertions(+), 67 deletions(-)
utils/v4l2-tracer/libv4l2tracer.cpp +6 -6
index a9f039c7..fc6f3939 100644
@@ -69,7 +69,7 @@ int open(const char *path, int oflag, ...)
 	int fd = (*original_open)(path, oflag, mode);
 
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "fd: %d, path: %s\n", fd, path);
 	}
 
@@ -82,7 +82,7 @@ int open(const char *path, int oflag, ...)
 	}
 
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 		print_devices();
 	}
 
@@ -105,7 +105,7 @@ int open64(const char *path, int oflag, ...)
 	int fd = (*original_open64)(path, oflag, mode);
 
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "fd: %d, path: %s\n", fd, path);
 	}
 
@@ -118,7 +118,7 @@ int open64(const char *path, int oflag, ...)
 	}
 
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 		print_devices();
 	}
 
@@ -136,7 +136,7 @@ int close(int fd)
 
 	std::string path = get_device(fd);
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "fd: %d, path: %s\n", fd, path.c_str());
 	}
 
@@ -155,7 +155,7 @@ int close(int fd)
 	}
 
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 		print_devices();
 	}
 
utils/v4l2-tracer/retrace-helper.cpp +8 -8
index 03b0466b..427e81ae 100644
@@ -119,7 +119,7 @@ std::string get_path_retrace_from_path_trace(std::string path_trace, json_object
 	if (is_media && (getenv("V4L2_TRACER_OPTION_SET_MEDIA_DEVICE") != nullptr)) {
 		path_media = getenv("V4L2_TRACER_OPTION_SET_MEDIA_DEVICE");
 		if (is_debug()) {
-			fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 			fprintf(stderr, "Use path set by user: %s ", path_media.c_str());
 		}
 		return path_media;
@@ -127,7 +127,7 @@ std::string get_path_retrace_from_path_trace(std::string path_trace, json_object
 	if (is_video && (getenv("V4L2_TRACER_OPTION_SET_VIDEO_DEVICE") != nullptr)) {
 		path_video = getenv("V4L2_TRACER_OPTION_SET_VIDEO_DEVICE");
 		if (is_debug()) {
-			fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 			fprintf(stderr, "Use path set by user: %s ", path_video.c_str());
 		}
 		return path_video;
@@ -143,7 +143,7 @@ std::string get_path_retrace_from_path_trace(std::string path_trace, json_object
 
 	path_media = get_path_media(driver);
 	if (path_media.empty()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "warning: driver: %s not found\n", driver.c_str());
 		return "";
 	}
@@ -206,11 +206,11 @@ void write_to_output_buffer(unsigned char *buffer_pointer, int bytesused, json_o
 				i++;
 				byteswritten++;
 			} catch (std::invalid_argument& ia) {
-				fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "\'%s\' is an invalid argument.\n",
 				        compressed_video_data.substr(i,2).c_str());
 			} catch (std::out_of_range& oor) {
-				fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "\'%s\' is out of range.\n",
 				        compressed_video_data.substr(i,2).c_str());
 			}
@@ -218,7 +218,7 @@ void write_to_output_buffer(unsigned char *buffer_pointer, int bytesused, json_o
 	}
 
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "bytesused: %d, byteswritten: %d\n", bytesused, byteswritten);
 	}
 }
@@ -232,7 +232,7 @@ void compare_program_versions(json_object *v4l2_tracer_info_obj)
 		package_version_trace = json_object_get_string(package_version_obj);
 	std::string package_version_retrace = PACKAGE_VERSION;
 	if (package_version_trace != package_version_retrace) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "warning: trace package version \'%s\' does not match current: \'%s\':\n",
 		        package_version_trace.c_str(), package_version_retrace.c_str());
 		print_v4l2_tracer_info();
@@ -246,7 +246,7 @@ void compare_program_versions(json_object *v4l2_tracer_info_obj)
 		git_sha_trace = json_object_get_string(git_sha_obj);
 	std::string git_sha_retrace = (STRING(GIT_SHA));
 	if (git_sha_trace != git_sha_retrace) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "warning: sha in trace file \'%s\' does not match current sha: \'%s\'\n",
 		        git_sha_trace.c_str(),  git_sha_retrace.c_str());
 		print_v4l2_tracer_info();
utils/v4l2-tracer/retrace.cpp +26 -26

206 lines not on this page · raw message

utils/v4l2-tracer/trace-helper.cpp +9 -9
index 0030272b..383a957f 100644
@@ -20,7 +20,7 @@ bool is_video_or_media_device(const char *path)
 void add_device(int fd, std::string path)
 {
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "fd: %d, path: %s\n", fd, path.c_str());
 	}
 	std::pair<int, std::string> new_pair = std::make_pair(fd, path);
@@ -56,7 +56,7 @@ void print_decode_order(void)
 void set_decode_order(long decode_order)
 {
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "%ld\n", decode_order);
 	}
 
@@ -183,7 +183,7 @@ long get_buffer_bytesused_trace(int fd, __u32 offset)
 void set_buffer_display_order(int fd, __u32 offset, long display_order)
 {
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "%ld\n", display_order);
 	}
 	for (auto &b : ctx_trace.buffers) {
@@ -259,7 +259,7 @@ void s_ext_ctrls_setup(struct v4l2_ext_controls *ext_controls)
 		return;
 
 	if (is_debug())
-		fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 
 	/*
 	 * Since userspace sends H264 frames out of order, get information
@@ -282,7 +282,7 @@ void s_ext_ctrls_setup(struct v4l2_ext_controls *ext_controls)
 			int pic_order_cnt_lsb = ctrl.p_h264_decode_params->pic_order_cnt_lsb;
 
 			if (is_debug()) {
-				fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "\tprev_pic_order_cnt_lsb: %d\n", prev_pic_order_cnt_lsb);
 				fprintf(stderr, "\tprev_pic_order_cnt_msb: %ld\n", prev_pic_order_cnt_msb);
 				fprintf(stderr, "\tpic_order_cnt_lsb: %d\n", pic_order_cnt_lsb);
@@ -314,7 +314,7 @@ void s_ext_ctrls_setup(struct v4l2_ext_controls *ext_controls)
 			}
 
 			if (is_debug()) {
-				fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "\tpic_order_cnt_msb: %ld\n", pic_order_cnt_msb);
 			}
 			ctx_trace.fmt.h264.pic_order_cnt_lsb = pic_order_cnt_lsb;
@@ -330,7 +330,7 @@ void s_ext_ctrls_setup(struct v4l2_ext_controls *ext_controls)
 void qbuf_setup(struct v4l2_buffer *buf)
 {
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "%s, index: %d\n", buftype2s((int) buf->type).c_str(), buf->index);
 	}
 
@@ -366,7 +366,7 @@ void qbuf_setup(struct v4l2_buffer *buf)
 		set_buffer_display_order(buf_fd, buf_offset, get_decode_order());
 
 		if (is_debug()) {
-			fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 			print_decode_order();
 			print_buffers_trace();
 		}
@@ -377,7 +377,7 @@ void streamoff_cleanup(v4l2_buf_type buf_type)
 {
 
 	if (is_debug())
-		fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 	if (is_verbose() || (getenv("V4L2_TRACER_OPTION_WRITE_DECODED_TO_YUV_FILE") != nullptr)) {
 		fprintf(stderr, "VIDIOC_STREAMOFF: %s\n", buftype2s(buf_type).c_str());
 		fprintf(stderr, "%s, %s %s, width: %d, height: %d\n",
utils/v4l2-tracer/trace.cpp +2 -2
index a393d0d4..138654af 100644
@@ -182,7 +182,7 @@ void trace_mem_decoded(void)
 			if (it->bytesused < expected_length)
 				break;
 			if (is_debug()) {
-				fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "displaying: %ld, %s, index: %d\n",
 				        it->display_order, buftype2s(it->type).c_str(), it->index);
 			}
@@ -418,7 +418,7 @@ void trace_v4l2_ext_control(void *arg, json_object *parent_obj, std::string key_
 		break;
 	default:
 		if (p->size) {
-			fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 			fprintf(stderr, "warning: cannot trace control: %s\n", val2s(p->id, control_val_def).c_str());
 		} else {
 			json_object_object_add(v4l2_ext_control_obj, "value", json_object_new_int(p->value));
utils/v4l2-tracer/v4l2-tracer-common.cpp +2 -2
index 869347a1..3f4609aa 100644
@@ -211,10 +211,10 @@ long s2number(const char *char_str)
 	try {
 		num = std::strtol(str.c_str(), nullptr, 0); /* base is auto-detected */
 	} catch (std::invalid_argument& ia) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "string \'%s\' is invalid\n", str.c_str());
 	} catch (std::out_of_range& oor) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "string \'%s\' is out of range\n", str.c_str());
 	}
 	return num;
utils/v4l2-tracer/v4l2-tracer-common.h +6 -0
index ab8b78e3..385cb1e9 100644
@@ -39,6 +39,12 @@
 #define STRERR(x) strerror(x)
 #endif
 
+#ifndef __FILE_NAME__
+#define __FNAME__ __FILE__
+#else
+#define __FNAME__ __FILE_NAME__
+#endif
+
 struct val_def {
 	__s64 val;
 	const char *str;
utils/v4l2-tracer/v4l2-tracer.cpp +14 -14
index e3f002a9..1c969510 100644
@@ -14,7 +14,7 @@ pid_t tracee_pid = 0;
 
 void v4l2_tracer_sig_handler(int signum)
 {
-	fprintf(stderr, "%s:%s:%d: received: %d\n", __FILE__, __func__, __LINE__, signum);
+	fprintf(stderr, "%s:%s:%d: received: %d\n", __FNAME__, __func__, __LINE__, signum);
 	kill(tracee_pid, signum);
 	/* Wait for tracee to handle the signal first before v4l2-tracer exits. */
 	wait(nullptr);
@@ -80,7 +80,7 @@ int get_options(int argc, char *argv[])
 			try {
 				std::stoi(device_num, nullptr, 0);
 			} catch (std::exception& e) {
-				fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "can't convert <dev> \'%s\' to integer\n", device_num.c_str());
 				return -1;
 			}
@@ -89,7 +89,7 @@ int get_options(int argc, char *argv[])
 				path_video += optarg;
 				setenv("V4L2_TRACER_OPTION_SET_VIDEO_DEVICE", path_video.c_str(), 0);
 			} else {
-				fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "cannot use device number\'%s\'\n", device_num.c_str());
 				return -1;
 			}
@@ -107,7 +107,7 @@ int get_options(int argc, char *argv[])
 			try {
 				std::stoi(device_num, nullptr, 0);
 			} catch (std::exception& e) {
-				fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "can't convert <dev> \'%s\' to integer\n", device_num.c_str());
 				return -1;
 			}
@@ -116,7 +116,7 @@ int get_options(int argc, char *argv[])
 				path_media += optarg;
 				setenv("V4L2_TRACER_OPTION_SET_MEDIA_DEVICE", path_media.c_str(), 0);
 			} else {
-				fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+				fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 				fprintf(stderr, "cannot use device number\'%s\'\n", device_num.c_str());
 				return -1;
 			}
@@ -150,7 +150,7 @@ int clean(std::string trace_filename)
 {
 	FILE *trace_file = fopen(trace_filename.c_str(), "r");
 	if (trace_file == nullptr) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "cannot open \'%s\'\n", trace_filename.c_str());
 		return 1;
 	}
@@ -160,7 +160,7 @@ int clean(std::string trace_filename)
 	std::string clean_filename = "clean_" + trace_filename;
 	FILE *clean_file = fopen(clean_filename.c_str(), "w");
 	if (clean_file == nullptr) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "cannot open \'%s\'\n", clean_filename.c_str());
 		return 1;
 	}
@@ -215,7 +215,7 @@ int tracer(int argc, char *argv[], bool retrace)
 	if (retrace) {
 		std::string trace_file = argv[optind];
 		if (trace_file.find(".json") == std::string::npos) {
-			fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 			fprintf(stderr, "Trace file \'%s\' must have .json file extension\n",
 			        trace_file.c_str());
 			print_usage();
@@ -321,7 +321,7 @@ int tracer(int argc, char *argv[], bool retrace)
 	if (tracee_pid == 0) {
 
 		if (is_debug()) {
-			fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 			fprintf(stderr, "tracee: ");
 			for (int i = 0; i < exec_index; i++)
 				fprintf(stderr,"%s ", exec[i]);
@@ -330,7 +330,7 @@ int tracer(int argc, char *argv[], bool retrace)
 
 		execvpe(exec[0], (char* const*) exec, environ);
 
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);
 		fprintf(stderr, "could not execute application \'%s\'", exec[0]);
 		perror(" ");
 		return errno;
@@ -373,13 +373,13 @@ int main(int argc, char *argv[])
 
 	if (ret < 0) {
 		if (is_debug())
-			fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 		return ret;
 	}
 
 	if (optind == argc) {
 		if (is_debug())
-			fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 		print_usage();
 		return ret;
 	}
@@ -388,7 +388,7 @@ int main(int argc, char *argv[])
 
 	if (optind == argc) {
 		if (is_debug())
-			fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 		print_usage();
 		return ret;
 	}
@@ -412,7 +412,7 @@ int main(int argc, char *argv[])
 		ret = clean (argv[optind]);
 	} else {
 		if (is_debug()) {
-			fprintf(stderr, "%s:%s:%d\n", __FILE__, __func__, __LINE__);
+			fprintf(stderr, "%s:%s:%d\n", __FNAME__, __func__, __LINE__);
 			fprintf(stderr, "tracee: ");
 			for (int i = 0; i < argc; i++)
 				fprintf(stderr,"%s ", argv[i]);
Signature · 1 line
2.39.1
#1 lore raw
Quoted 20 lines · Deborah Brouwer

Use __FILE_NAME__ if available to avoid printing the entire relative path in verbose and debug messages, otherwise fall back to __FILE__.

---
 utils/v4l2-tracer/libv4l2tracer.cpp      | 12 +++---
 utils/v4l2-tracer/retrace-helper.cpp     | 16 ++++----
 utils/v4l2-tracer/retrace.cpp            | 52 ++++++++++++------------
 utils/v4l2-tracer/trace-helper.cpp       | 18 ++++----
 utils/v4l2-tracer/trace.cpp              |  4 +-
 utils/v4l2-tracer/v4l2-tracer-common.cpp |  4 +-
 utils/v4l2-tracer/v4l2-tracer-common.h   |  6 +++
 utils/v4l2-tracer/v4l2-tracer.cpp        | 28 ++++++-------
 8 files changed, 73 insertions(+), 67 deletions(-)
utils/v4l2-tracer/libv4l2tracer.cpp +0 -0
index a9f039c7..fc6f3939 100644

utils/v4l2-tracer/libv4l2tracer.cpp int open(const char *path, int oflag, ...) · line 72

Quoted 5 lines
utils/v4l2-tracer/libv4l2tracer.cpp +1 -1
@@ -69,7 +69,7 @@ int open(const char *path, int oflag, ...)
 	int fd = (*original_open)(path, oflag, mode);
 
 	if (is_debug()) {
-		fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+		fprintf(stderr, "%s:%s:%d: ", __FNAME__, __func__, __LINE__);

That's not quite what I had in mind.

All these messages are all the same, it's much better to introduce a macro for it, similar to e.g. the info macro in v4l2-compliance.h.

That way these '__FILE__, __func__, __LINE__' bits are only used in the macro, and it simplifies all these messages in v4l2-tracer.

Something like this goes into trace.h:

#ifndef __FILE_NAME__
#define __FILE_NAME__ __FILE__
#endif

#define info(fmt, args...)                                      \
        do {                                                    \
                fprintf(stderr, "%s:%s:%d" fmt, ##args, __FILE_NAME__, __func__, __LINE__);       \
        } while (0)

utils/v4l2-tracer/libv4l2tracer.cpp int open(const char *path, int oflag, ...) · line 73

Quoted 1 line
utils/v4l2-tracer/libv4l2tracer.cpp +0 -0
 		fprintf(stderr, "fd: %d, path: %s\n", fd, path);

And then this becomes:

		info(": fd: %d, path: %s\n", fd, path);

I'm not sure if calling it 'info' is the right name in this case, I leave that to you.

Regards,

Hans