[Pcsclite-cvs-commit] r6696 - trunk/PCSC/src
ludovic.rousseau at free.fr
ludovic.rousseau at free.fr
Tue Jul 30 12:55:15 UTC 2013
Author: rousseau
Date: 2013-07-30 12:55:15 +0000 (Tue, 30 Jul 2013)
New Revision: 6696
Modified:
trunk/PCSC/src/pcscdaemon.c
trunk/PCSC/src/utils.c
Log:
Check read(2) and write(2) returned value for pcscd.pid file
Fix compiler warnings:
utils.c: In function `GetDaemonPid':
utils.c:45:3: warning: ignoring return value of `read', declared with attribute warn_unused_result [-Wunused-result]
pcscdaemon.c: In function ?\226?\128?\152main?\226?\128?\153:
pcscdaemon.c:543:4: warning: ignoring return value of ?\226?\128?\152write?\226?\128?\153, declared with attribute warn_unused_result [-Wunused-result]
Modified: trunk/PCSC/src/pcscdaemon.c
===================================================================
--- trunk/PCSC/src/pcscdaemon.c 2013-07-30 12:41:23 UTC (rev 6695)
+++ trunk/PCSC/src/pcscdaemon.c 2013-07-30 12:55:15 UTC (rev 6696)
@@ -538,9 +538,16 @@
if (f != -1)
{
char pid[PID_ASCII_SIZE];
+ ssize_t r;
(void)snprintf(pid, sizeof(pid), "%u\n", (unsigned) getpid());
- (void)write(f, pid, strlen(pid));
+ r = write(f, pid, strlen(pid));
+ if (r < 0)
+ {
+ Log2(PCSC_LOG_CRITICAL,
+ "writting " PCSCLITE_RUN_PID " failed: %s",
+ strerror(errno));
+ }
(void)close(f);
/* set mode so that the file is world readable even is umask is
Modified: trunk/PCSC/src/utils.c
===================================================================
--- trunk/PCSC/src/utils.c 2013-07-30 12:41:23 UTC (rev 6695)
+++ trunk/PCSC/src/utils.c 2013-07-30 12:55:15 UTC (rev 6696)
@@ -41,11 +41,19 @@
if (fd >= 0)
{
char pid_ascii[PID_ASCII_SIZE];
+ ssize_t r;
- (void)read(fd, pid_ascii, PID_ASCII_SIZE);
+ r = read(fd, pid_ascii, sizeof pid_ascii);
+ if (r < 0)
+ {
+ Log2(PCSC_LOG_CRITICAL, "Reading " PCSCLITE_RUN_PID " failed: %s",
+ strerror(errno));
+ pid = -1;
+ }
+ else
+ pid = atoi(pid_ascii);
(void)close(fd);
- pid = atoi(pid_ascii);
}
else
{
More information about the Pcsclite-cvs-commit
mailing list