Fix sem_getvalue

Paul Kunysch paul.kunysch@emsys.de
Wed Sep 18 09:53:00 GMT 2013


Hello

In 1.7.24 and 1.7.25 sem_getvalue() returns the current value instead of 
setting the out-parameter and returning 0/-1 for success/error.

I attached a simple fix.

I don't know if this should be further improved by setting errno to 
EINVAL if STATUS_INVALID_HANDLE == status.

Unfortunately I wasn't able to run and extend the unit tests.  Running 
"make check" fails with "No rule to make target `dataascii.o', needed by 
`libltp.a'".  The VPATH seems to be extended correctly.

Kind regards,
Paul
-- 

Kunysch, Paul
Software Development

emsys Embedded Systems GmbH
Werner von Siemens Str. 20
98693 Ilmenau
Germany

Tel.: +49 3677 68977-16   Fax: +49 3677 68977-19
E-Mail: paul.kunysch@emsys.de
Internet: www.emsys.de

CEO: Dr.-Ing. Karsten Pahnke
office: Ilmenau
Register of commerce in county court Jena: HRB 304988
-------------- next part --------------
Index: winsup/cygwin/thread.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/thread.cc,v
retrieving revision 1.285
diff -u -p -r1.285 thread.cc
--- winsup/cygwin/thread.cc	23 Jul 2013 14:15:20 -0000	1.285
+++ winsup/cygwin/thread.cc	17 Sep 2013 17:45:26 -0000
@@ -3443,9 +3443,8 @@ semaphore::_getvalue (int *sval)
 
   status = NtQuerySemaphore (win32_obj_id, SemaphoreBasicInformation, &sbi,
 			     sizeof sbi, NULL);
-  if (NT_SUCCESS (status))
-    return sbi.CurrentCount;
-  return startvalue;
+  *sval = (NT_SUCCESS(status)) ? sbi.CurrentCount : startvalue;
+  return 0;
 }
 
 int
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3973 bytes
Desc: S/MIME Kryptografische Unterschrift
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20130918/ba26b480/attachment.p7s>


More information about the Cygwin-patches mailing list