Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jan 2013 05:00:51 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r245491 - head/usr.sbin/cpucontrol
Message-ID:  <201301160500.r0G50pWE086481@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Wed Jan 16 05:00:51 2013
New Revision: 245491
URL: http://svnweb.freebsd.org/changeset/base/245491

Log:
  Avoid clobbering errno with a call to fprintf
  
  PR:		bin/173923
  Submitted by:	Garrett Cooper <yanegomi@gmail.com>
  Approved by:	cperciva
  MFC After:	3 days

Modified:
  head/usr.sbin/cpucontrol/intel.c
  head/usr.sbin/cpucontrol/via.c

Modified: head/usr.sbin/cpucontrol/intel.c
==============================================================================
--- head/usr.sbin/cpucontrol/intel.c	Wed Jan 16 04:45:45 2013	(r245490)
+++ head/usr.sbin/cpucontrol/intel.c	Wed Jan 16 05:00:51 2013	(r245491)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include <unistd.h>
 #include <fcntl.h>
 #include <err.h>
+#include <errno.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -266,7 +267,9 @@ matched:
 	args.size = data_size;
 	error = ioctl(devfd, CPUCTL_UPDATE, &args);
 	if (error < 0) {
+               error = errno;
 		fprintf(stderr, "failed.\n");
+               errno = error;
 		WARN(0, "ioctl()");
 		goto fail;
 	}

Modified: head/usr.sbin/cpucontrol/via.c
==============================================================================
--- head/usr.sbin/cpucontrol/via.c	Wed Jan 16 04:45:45 2013	(r245490)
+++ head/usr.sbin/cpucontrol/via.c	Wed Jan 16 05:00:51 2013	(r245491)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include <unistd.h>
 #include <fcntl.h>
 #include <err.h>
+#include <errno.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -203,7 +204,9 @@ via_update(const char *dev, const char *
 	args.size = data_size;
 	error = ioctl(devfd, CPUCTL_UPDATE, &args);
 	if (error < 0) {
+               error = errno;
 		fprintf(stderr, "failed.\n");
+               errno = error;
 		WARN(0, "ioctl()");
 		goto fail;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301160500.r0G50pWE086481>