From owner-svn-src-head@freebsd.org Thu Aug 10 13:00:11 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE622DD1EA2; Thu, 10 Aug 2017 13:00:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D2C683326; Thu, 10 Aug 2017 13:00:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7AD0AvK091860; Thu, 10 Aug 2017 13:00:10 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7AD0AIN091859; Thu, 10 Aug 2017 13:00:10 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708101300.v7AD0AIN091859@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 10 Aug 2017 13:00:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322355 - head/sys/compat/linuxkpi/common/include/linux X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/compat/linuxkpi/common/include/linux X-SVN-Commit-Revision: 322355 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Aug 2017 13:00:11 -0000 Author: hselasky Date: Thu Aug 10 13:00:10 2017 New Revision: 322355 URL: https://svnweb.freebsd.org/changeset/base/322355 Log: Fixes for wait event in the LinuxKPI. These are regression issues after r319757. 1) Correct the return value from __wait_event_common() from 1 to 0 in case the timeout is specified as MAX_SCHEDULE_TIMEOUT. In the other case __ret is zero and will be substituted in the last part of the macro with the appropriate value before return. 2) Make sure the "timeout" argument is casted to "int" before evaluating negativity. Else the signedness of a "long" might be checked instead of the signedness of an integer. 3) The wait_event() function should not have a return value. Found by: KrishnamRaju ErapaRaju MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/wait.h Modified: head/sys/compat/linuxkpi/common/include/linux/wait.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/wait.h Thu Aug 10 12:51:04 2017 (r322354) +++ head/sys/compat/linuxkpi/common/include/linux/wait.h Thu Aug 10 13:00:10 2017 (r322355) @@ -127,16 +127,14 @@ int linux_wait_event_common(wait_queue_head_t *, wait_ */ #define __wait_event_common(wqh, cond, timeout, state, lock) ({ \ DEFINE_WAIT(__wq); \ - const int __timeout = (timeout) < 1 ? 1 : (timeout); \ + const int __timeout = ((int)(timeout)) < 1 ? 1 : (timeout); \ int __start = ticks; \ int __ret = 0; \ \ for (;;) { \ linux_prepare_to_wait(&(wqh), &__wq, state); \ - if (cond) { \ - __ret = 1; \ + if (cond) \ break; \ - } \ __ret = linux_wait_event_common(&(wqh), &__wq, \ __timeout, state, lock); \ if (__ret != 0) \ @@ -158,10 +156,10 @@ int linux_wait_event_common(wait_queue_head_t *, wait_ __ret; \ }) -#define wait_event(wqh, cond) ({ \ - __wait_event_common(wqh, cond, MAX_SCHEDULE_TIMEOUT, \ +#define wait_event(wqh, cond) do { \ + (void) __wait_event_common(wqh, cond, MAX_SCHEDULE_TIMEOUT, \ TASK_UNINTERRUPTIBLE, NULL); \ -}) +} while (0) #define wait_event_timeout(wqh, cond, timeout) ({ \ __wait_event_common(wqh, cond, timeout, TASK_UNINTERRUPTIBLE, \