public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* Re: Fix sem_getvalue
       [not found] <52389689.1030801@emsys.de>
@ 2013-09-25 10:42 ` Paul Kunysch
  2013-09-25 14:46   ` Christopher Faylor
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Kunysch @ 2013-09-25 10:42 UTC (permalink / raw)
  To: cygwin-patches

[-- Attachment #1: Type: text/plain, Size: 675 bytes --]

> That looks like a reasonable fix.  Did you trace through all of the
> callers of semaphore::_getvalue to make sure that some of them aren't
> relying on the old behavior?

I did not look for other callers.

I just wrote a very simple test for sem_getvalue() and copied different 
cygwin1.dll versions to my test-application.
-- 

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


[-- Attachment #2: S/MIME Kryptografische Unterschrift --]
[-- Type: application/pkcs7-signature, Size: 3973 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix sem_getvalue
  2013-09-25 10:42 ` Fix sem_getvalue Paul Kunysch
@ 2013-09-25 14:46   ` Christopher Faylor
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Faylor @ 2013-09-25 14:46 UTC (permalink / raw)
  To: cygwin-patches

On Wed, Sep 25, 2013 at 12:41:17PM +0200, Paul Kunysch wrote:
>> That looks like a reasonable fix.  Did you trace through all of the
>> callers of semaphore::_getvalue to make sure that some of them aren't
>> relying on the old behavior?
>
>I did not look for other callers.
>
>I just wrote a very simple test for sem_getvalue() and copied different 
>cygwin1.dll versions to my test-application.

I was being too vague here.  You made what looks like a reasonable
change but it is to a low-level function which is called by more than
one place.  I was hoping that, since you wanted to see this fixed, you
might also be willing to make sure that your change doesn't break
anything else.  But, I didn't say that so, my bad.

I've checked in a modified version of your patch along with a ChangeLog.

Thanks.

cgf

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix sem_getvalue
  2013-09-18  9:53 Paul Kunysch
@ 2013-09-18 18:12 ` Christopher Faylor
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Faylor @ 2013-09-18 18:12 UTC (permalink / raw)
  To: cygwin-patches

On Wed, Sep 18, 2013 at 11:53:20AM +0200, Paul Kunysch wrote:
>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.

That looks like a reasonable fix.  Did you trace through all of the
callers of semaphore::_getvalue to make sure that some of them aren't
relying on the old behavior?

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

That sounds reasonable too.

>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.

The tests are in a severe case of bit rot unfortunately.  It would be nice
if someone made it a mission to improve Cygwin's testing from nonexistent to
something but that is a very unrewarding a job.

cgf

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Fix sem_getvalue
@ 2013-09-18  9:53 Paul Kunysch
  2013-09-18 18:12 ` Christopher Faylor
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Kunysch @ 2013-09-18  9:53 UTC (permalink / raw)
  To: cygwin-patches


[-- Attachment #1.1: Type: text/plain, Size: 861 bytes --]

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

[-- Attachment #1.2: patch.txt --]
[-- Type: text/plain, Size: 668 bytes --]

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

[-- Attachment #2: S/MIME Kryptografische Unterschrift --]
[-- Type: application/pkcs7-signature, Size: 3973 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-25 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <52389689.1030801@emsys.de>
2013-09-25 10:42 ` Fix sem_getvalue Paul Kunysch
2013-09-25 14:46   ` Christopher Faylor
2013-09-18  9:53 Paul Kunysch
2013-09-18 18:12 ` Christopher Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).