From patchwork Sat Jun 3 15:03:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 9764407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1951460365 for ; Sat, 3 Jun 2017 15:03:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07647284FF for ; Sat, 3 Jun 2017 15:03:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE18528579; Sat, 3 Jun 2017 15:03:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13BED284FF for ; Sat, 3 Jun 2017 15:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750876AbdFCPDw (ORCPT ); Sat, 3 Jun 2017 11:03:52 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:33284 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750775AbdFCPDw (ORCPT ); Sat, 3 Jun 2017 11:03:52 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 5450520E87; Sat, 3 Jun 2017 17:03:49 +0200 (CEST) Received: from localhost (132.230.147.77.rev.sfr.net [77.147.230.132]) by mail.free-electrons.com (Postfix) with ESMTPSA id B1D6A20E1A; Sat, 3 Jun 2017 17:03:38 +0200 (CEST) From: Thomas Petazzoni To: linux-modules@vger.kernel.org Cc: Thomas Petazzoni Subject: [PATCH kmod] shared/util.c: assert_cc() can only be used inside functions Date: Sat, 3 Jun 2017 17:03:22 +0200 Message-Id: <1496502202-9832-1-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.7.4 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP shared/macro.h has two versions of assert_cc, one that uses gcc _Static_assert(), which requires recent enough gcc versions, and one that uses a fake array to trigger a build error. The latter can only work inside functions, so assert_cc() should only be used inside functions. Fixes the following build failure when building kmod with old gcc versions such as gcc 4.3.x: shared/util.c:52: error: expected identifier or '(' before 'do' shared/util.c:52: error: expected identifier or '(' before 'while' Signed-off-by: Thomas Petazzoni --- shared/util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shared/util.c b/shared/util.c index 9de080a..fd2028d 100644 --- a/shared/util.c +++ b/shared/util.c @@ -49,8 +49,6 @@ static const struct kmod_ext { { } }; -assert_cc(EAGAIN == EWOULDBLOCK); - /* string handling functions and memory allocations */ /* ************************************************************************ */ @@ -201,6 +199,8 @@ ssize_t read_str_safe(int fd, char *buf, size_t buflen) size_t todo = buflen - 1; size_t done = 0; + assert_cc(EAGAIN == EWOULDBLOCK); + do { ssize_t r = read(fd, buf + done, todo); @@ -226,6 +226,8 @@ ssize_t write_str_safe(int fd, const char *buf, size_t buflen) size_t todo = buflen; size_t done = 0; + assert_cc(EAGAIN == EWOULDBLOCK); + do { ssize_t r = write(fd, buf + done, todo);