This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Convert utmp{x}name to int, return useful value. Define _PATH_UTMPX


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=80a800978b1c9cb27940a08ec05bf806db3b282d

commit 80a800978b1c9cb27940a08ec05bf806db3b282d
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Thu Jan 7 15:40:40 2016 +0100

    Convert utmp{x}name to int, return useful value.  Define _PATH_UTMPX
    
    	* syscalls.cc (utmpname): Convert to int.  Return 0 if strdup
    	worked, -1 otherwise.
    	* include/utmpx.h (_PATH_UTMPX): Define as _PATH_UTMP.
    	(utmpxname): Declare as int function.
    	* include/sys/utmp.h (utmpname): Ditto.
    	* include/cygwin/version.h: Bump API minor version.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/include/cygwin/version.h |  3 ++-
 winsup/cygwin/include/sys/utmp.h       |  2 +-
 winsup/cygwin/include/utmpx.h          |  3 ++-
 winsup/cygwin/release/2.4.0            |  3 +++
 winsup/cygwin/syscalls.cc              | 14 +++++++++-----
 winsup/doc/new-features.xml            |  4 ++++
 6 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index c5b75ee..5d79cc3 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -474,13 +474,14 @@ details. */
       290: Add sysconf cache handling.
       291: Export aligned_alloc, at_quick_exit, quick_exit.
       292: Export rpmatch.
+      293: Convert utmpname/utmpxname to int.
      */
 
      /* Note that we forgot to bump the api for ualarm, strtoll, strtoull,
 	sigaltstack, sethostname. */
 
 #define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 292
+#define CYGWIN_VERSION_API_MINOR 293
 
      /* There is also a compatibity version number associated with the
 	shared memory regions.  It is incremented when incompatible
diff --git a/winsup/cygwin/include/sys/utmp.h b/winsup/cygwin/include/sys/utmp.h
index 8a63b34..b14fc08 100644
--- a/winsup/cygwin/include/sys/utmp.h
+++ b/winsup/cygwin/include/sys/utmp.h
@@ -40,7 +40,7 @@ extern struct utmp *getutline (const struct utmp *);
 extern struct utmp *pututline (const struct utmp *);
 extern void endutent (void);
 extern void setutent (void);
-extern void utmpname (const char *);
+extern int utmpname (const char *);
 
 void login (const struct utmp *);
 int logout (const char *);
diff --git a/winsup/cygwin/include/utmpx.h b/winsup/cygwin/include/utmpx.h
index 548ad80..53b04ed 100644
--- a/winsup/cygwin/include/utmpx.h
+++ b/winsup/cygwin/include/utmpx.h
@@ -12,6 +12,7 @@
 #include <cygwin/utmp.h>
 #include <sys/time.h>
 
+#define _PATH_UTMPX _PATH_UTMP
 #define UTMPX_FILE _PATH_UTMP
 
 #ifdef __cplusplus
@@ -46,7 +47,7 @@ extern struct utmpx *getutxid (const struct utmpx *id);
 extern struct utmpx *getutxline (const struct utmpx *line);
 extern struct utmpx *pututxline (const struct utmpx *utmpx);
 extern void setutxent (void);
-extern void utmpxname (const char *file);
+extern int utmpxname (const char *file);
 extern void updwtmpx (const char *file, const struct utmpx *utmpx);
 
 #ifdef __cplusplus
diff --git a/winsup/cygwin/release/2.4.0 b/winsup/cygwin/release/2.4.0
index 918fd5c..4feff5b 100644
--- a/winsup/cygwin/release/2.4.0
+++ b/winsup/cygwin/release/2.4.0
@@ -42,6 +42,9 @@ What changed:
 - Fix (numeric and monetary) decimal point and thousands separator in
   fa_IR and ps_AF locales to be aligned with Linux.
 
+- utmpname/utmpxname are now defined as int functions as on Linux.
+  Addresses: https://cygwin.com/ml/cygwin/2015-12/msg00320.html
+
 
 Bug Fixes
 ---------
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 9d01955..3dd6af1 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3955,7 +3955,7 @@ endutent ()
     }
 }
 
-extern "C" void
+extern "C" int
 utmpname (const char *file)
 {
   __try
@@ -3964,13 +3964,17 @@ utmpname (const char *file)
 	{
 	  endutent ();
 	  utmp_file = strdup (file);
-	  debug_printf ("New UTMP file: %s", utmp_file);
-	  return;
+	  if (utmp_file)
+	    {
+	      debug_printf ("New UTMP file: %s", utmp_file);
+	      return 0;
+	    }
 	}
     }
-  __except (NO_ERROR) {}
+  __except (EFAULT) {}
   __endtry
-  debug_printf ("Invalid file");
+  debug_printf ("Setting UTMP file failed");
+  return -1;
 }
 
 EXPORT_ALIAS (utmpname, utmpxname)
diff --git a/winsup/doc/new-features.xml b/winsup/doc/new-features.xml
index ff4b66f..b4b8435 100644
--- a/winsup/doc/new-features.xml
+++ b/winsup/doc/new-features.xml
@@ -52,6 +52,10 @@ Fix (numeric and monetary) decimal point and thousands separator in
 fa_IR and ps_AF locales to be aligned with Linux.
 </para></listitem>
 
+<listitem><para>
+utmpname/utmpxname are now defined as int functions as on Linux.
+</para></listitem>
+
 </itemizedlist>
 
 </sect2>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]