From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6939 64.71.128.0/18 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.posix-mq.general Subject: [PATCH 2/5] ext: fix type inconsistencies for int vs mqd_t retvals Date: Thu, 12 Jul 2012 12:45:38 -0700 Message-ID: <1342122341-24646-3-git-send-email-normalperson@yhbt.net> References: <1342122341-24646-1-git-send-email-normalperson@yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1342122355 30076 80.91.229.3 (12 Jul 2012 19:45:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 12 Jul 2012 19:45:55 +0000 (UTC) To: ruby.posix.mq@librelist.org Original-X-From: ruby.posix.mq@librelist.org Thu Jul 12 21:45:54 2012 Return-path: Envelope-to: gclrpg-ruby.posix.mq@m.gmane.org List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: ruby.posix.mq@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.posix-mq.general:106 Archived-At: Received: from zedshaw.xen.prgmr.com ([64.71.167.205]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SpPKk-00037J-Cv for gclrpg-ruby.posix.mq@m.gmane.org; Thu, 12 Jul 2012 21:45:54 +0200 Received: from zedshaw.xen.prgmr.com (localhost [IPv6:::1]) by zedshaw.xen.prgmr.com (Postfix) with ESMTP id 94ABF21E1F0 for ; Thu, 12 Jul 2012 19:54:46 +0000 (UTC) From: "ew@fbsd90-32.(none)" Somehow I mixed up return values for mq_* functions that return "int". This was noticed on FreeBSD where mqd_t is NOT an integer. --- ext/posix_mq/posix_mq.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c index 66f3f99..7a3dc14 100644 --- a/ext/posix_mq/posix_mq.c +++ b/ext/posix_mq/posix_mq.c @@ -468,9 +468,9 @@ static VALUE init(int argc, VALUE *argv, VALUE self) */ static VALUE s_unlink(VALUE self, VALUE name) { - mqd_t rv = mq_unlink(StringValueCStr(name)); + int rv = mq_unlink(StringValueCStr(name)); - if (rv == MQD_INVALID) + if (rv == -1) rb_sys_fail("mq_unlink"); return INT2NUM(1); @@ -489,12 +489,12 @@ static VALUE s_unlink(VALUE self, VALUE name) static VALUE _unlink(VALUE self) { struct posix_mq *mq = get(self, 0); - mqd_t rv; + int rv; assert(TYPE(mq->name) == T_STRING && "mq->name is not a string"); rv = mq_unlink(RSTRING_PTR(mq->name)); - if (rv == MQD_INVALID) + if (rv == -1) rb_sys_fail("mq_unlink"); return self; @@ -532,7 +532,7 @@ static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self) struct posix_mq *mq = get(self, 1); struct rw_args x; VALUE buffer, prio, timeout; - mqd_t rv; + int rv; struct timespec expire; rb_scan_args(argc, argv, "12", &buffer, &prio, &timeout); @@ -543,8 +543,8 @@ static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self) x.msg_prio = NIL_P(prio) ? 0 : NUM2UINT(prio); retry: - rv = (mqd_t)rb_thread_blocking_region(xsend, &x, RUBY_UBF_IO, 0); - if (rv == MQD_INVALID) { + rv = (int)rb_thread_blocking_region(xsend, &x, RUBY_UBF_IO, 0); + if (rv == -1) { if (errno == EINTR) goto retry; if (errno == EAGAIN && (sflags & PMQ_TRY)) @@ -570,7 +570,7 @@ static VALUE send0(VALUE self, VALUE buffer) { struct posix_mq *mq = get(self, 1); struct rw_args x; - mqd_t rv; + int rv; setup_send_buffer(&x, buffer); x.des = mq->des; @@ -578,8 +578,8 @@ static VALUE send0(VALUE self, VALUE buffer) x.msg_prio = 0; retry: - rv = (mqd_t)rb_thread_blocking_region(xsend, &x, RUBY_UBF_IO, 0); - if (rv == MQD_INVALID) { + rv = (int)rb_thread_blocking_region(xsend, &x, RUBY_UBF_IO, 0); + if (rv == -1) { if (errno == EINTR) goto retry; rb_sys_fail("mq_send"); @@ -838,14 +838,14 @@ static void thread_notify_fd(union sigval sv) static void my_mq_notify(mqd_t des, struct sigevent *not) { - mqd_t rv = mq_notify(des, not); + int rv = mq_notify(des, not); - if (rv == MQD_INVALID) { + if (rv == -1) { if (errno == ENOMEM) { rb_gc(); rv = mq_notify(des, not); } - if (rv == MQD_INVALID) + if (rv == -1) rb_sys_fail("mq_notify"); } } -- 1.7.11.rc0.55.gb2478aa