Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756805AbaGCJOs (ORCPT ); Thu, 3 Jul 2014 05:14:48 -0400 Received: from mx0.aculab.com ([213.249.233.131]:33319 "HELO mx0.aculab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1750908AbaGCJOp (ORCPT ); Thu, 3 Jul 2014 05:14:45 -0400 From: David Laight To: "'Alexei Starovoitov'" , Chema Gonzalez CC: "David S. Miller" , Ingo Molnar , Linus Torvalds , Steven Rostedt , Daniel Borkmann , Eric Dumazet , Peter Zijlstra , "Arnaldo Carvalho de Melo" , Jiri Olsa , "Thomas Gleixner" , "H. Peter Anvin" , "Andrew Morton" , Kees Cook , "Linux API" , Network Development , LKML Subject: RE: [PATCH RFC net-next 08/14] bpf: add eBPF verifier Thread-Topic: [PATCH RFC net-next 08/14] bpf: add eBPF verifier Thread-Index: AQHPlknrjjkyXHF39E2brFC82m+gmpuOD4YA Date: Thu, 3 Jul 2014 09:13:33 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1726BF1A@AcuExch.aculab.com> References: <1403913966-4927-1-git-send-email-ast@plumgrid.com> <1403913966-4927-9-git-send-email-ast@plumgrid.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id s639ErSk006034 From: Alexei Starovoitov > >> +#define _(OP) ({ int ret = OP; if (ret < 0) return ret; }) > > +1 to removing the _ macro. If you want to avoid the 3 lines (is there > > anything in the style guide against "if ((err=OP) < 0) ..." ?), at > > assignment and function call inside 'if' ? I don't like such style. > > > least use some meaningful macro name (DO_AND_CHECK, or something like > > that). It would have to be RETURN_IF_NEGATIVE(). But even then it is skipped by searches for 'return'. > Try replacing _ with any other name and see how bad it will look. > I tried with MACRO_NAME and with 'if (err) goto' and with 'if (err) return', > before I converged on _ macro. > I think it's a hidden gem of this patch. No, it is one of those things that 'seems like a good idea at the time', but causes grief much later on. Have you considered saving the error code into 'env' and making most of the functions return if an error is set? Then the calling code need not check the result of every function call. David ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?