[Pcsclite-cvs-commit] r6695 - trunk/PCSC/src/spy

ludovic.rousseau at free.fr ludovic.rousseau at free.fr
Tue Jul 30 12:41:24 UTC 2013


Author: rousseau
Date: 2013-07-30 12:41:23 +0000 (Tue, 30 Jul 2013)
New Revision: 6695

Modified:
   trunk/PCSC/src/spy/libpcscspy.c
Log:
Ignore the write(2) returned value

Using (void)write(...) is not enough to fool the compiler. I still get:
libpcscspy.c: In function `spy_line':
libpcscspy.c:200:2: warning: ignoring return value of `write', declared with attribute warn_unused_result [-Wunused-result]
libpcscspy.c:201:2: warning: ignoring return value of `write', declared with attribute warn_unused_result [-Wunused-result]
libpcscspy.c:202:2: warning: ignoring return value of `write', declared with attribute warn_unused_result [-Wunused-result]
libpcscspy.c: In function `spy_line_direct':
libpcscspy.c:173:2: warning: ignoring return value of `write', declared with attribute warn_unused_result [-Wunused-result]
libpcscspy.c:174:2: warning: ignoring return value of `write', declared with attribute warn_unused_result [-Wunused-result]
libpcscspy.c:175:2: warning: ignoring return value of `write', declared with attribute warn_unused_result [-Wunused-result]

The new code now uses:
ssize_t r;
r = write(...)
(void)r;


Modified: trunk/PCSC/src/spy/libpcscspy.c
===================================================================
--- trunk/PCSC/src/spy/libpcscspy.c	2013-07-30 12:36:46 UTC (rev 6694)
+++ trunk/PCSC/src/spy/libpcscspy.c	2013-07-30 12:41:23 UTC (rev 6695)
@@ -163,6 +163,7 @@
 static void spy_line_direct(char *line)
 {
 	char threadid[30];
+	ssize_t r;
 
 	/* spying disabled */
 	if (Log_fd < 0)
@@ -170,9 +171,10 @@
 
 	snprintf(threadid, sizeof threadid, "%lX@", pthread_self());
 	pthread_mutex_lock(&Log_fd_mutex);
-	(void)write(Log_fd, threadid, strlen(threadid));
-	(void)write(Log_fd, line, strlen(line));
-	(void)write(Log_fd, "\n", 1);
+	r = write(Log_fd, threadid, strlen(threadid));
+	r = write(Log_fd, line, strlen(line));
+	r = write(Log_fd, "\n", 1);
+	(void)r;
 	pthread_mutex_unlock(&Log_fd_mutex);
 }
 
@@ -182,6 +184,7 @@
 	char line[256];
 	int size;
 	char threadid[30];
+	ssize_t r;
 
 	/* spying disabled */
 	if (Log_fd < 0)
@@ -197,9 +200,10 @@
 	}
 	snprintf(threadid, sizeof threadid, "%lX@", pthread_self());
 	pthread_mutex_lock(&Log_fd_mutex);
-	(void)write(Log_fd, threadid, strlen(threadid));
-	(void)write(Log_fd, line, size);
-	(void)write(Log_fd, "\n", 1);
+	r = write(Log_fd, threadid, strlen(threadid));
+	r = write(Log_fd, line, size);
+	r = write(Log_fd, "\n", 1);
+	(void)r;
 	pthread_mutex_unlock(&Log_fd_mutex);
 }
 




More information about the Pcsclite-cvs-commit mailing list