From owner-freebsd-hackers@freebsd.org Tue Sep 13 20:10:25 2016 Return-Path: Delivered-To: freebsd-hackers@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 8163FBD7E05 for ; Tue, 13 Sep 2016 20:10:25 +0000 (UTC) (envelope-from cedric.blancher@gmail.com) Received: from mail-pa0-x22a.google.com (mail-pa0-x22a.google.com [IPv6:2607:f8b0:400e:c03::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 55661E18 for ; Tue, 13 Sep 2016 20:10:25 +0000 (UTC) (envelope-from cedric.blancher@gmail.com) Received: by mail-pa0-x22a.google.com with SMTP id wk8so10740627pab.1 for ; Tue, 13 Sep 2016 13:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=AFmKxpfxlqHkI8n43YxdgAxPNJyVNpA2svoYNpIe0Hw=; b=akgGBh3WxPRXkUVU+zQA/n1jWRPY/S0iVZY25RrV6XMNm1Z8lPGkKxHuW/gGaCFic+ 1kV27qXGZ6KUlIsHKwavfJ2CuWC/6xnIHyYyi9o4sAgzEAz0PloznWyo/teClYHqKqfj owjApDodQ5theUXPRfRLLapqTTf9yIXZQ/wRe7itc4J68J7iRnxJggljig4cJXMBSG3X /tueUuFLjWEJfwC1VoQrT6VWqCSvdauQO7MeaoYoFvPxhWZKotShXZMhwV9BGrW2J0yi nOoNeOK5llpAOIqJnphTHZfIRDaGo+21La42OO8YyLV2pG4DUhEmONe9e1Z5muS6iUSp VYrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=AFmKxpfxlqHkI8n43YxdgAxPNJyVNpA2svoYNpIe0Hw=; b=kCLQfolx8qxHdAiqwDixflnRWYg2ajDe/YpVQmYmC3EQTtg9ezOxHmf7UH75qozKD4 wEozx0vulyMxXoDp0AXGBUIq/s6ihuX/iGX2jcuWSQJ/rA088czwXhJI0Xm5mdFy33sl gRynSSW8q+/BOaeS1KjqTV9bvlNUYvvwXa8HYxhTH/CrP6KYWpMAYShr52tA4AkoFaOW i5FYwDJ13TdiIluyLm8VnhPsBH3UJbSXK+vswEaPCs4bJTF4uH3otPevsdek5kMdU764 SorX7upvyMvyORQwtZn9I3UWwskKLZhBYWe/TTD5LiunhBSUt3HT6k8icB7vZuO2XJIC 5Hvw== X-Gm-Message-State: AE9vXwPLo4ps88h+MBUCLKjRdC9cI+K3pK9zigUtdr2QEstJ2sa74L/LycChCTYgU8KvN47214rIE2yzBdio9A== X-Received: by 10.66.254.170 with SMTP id aj10mr4531026pad.124.1473797424945; Tue, 13 Sep 2016 13:10:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.217.137 with HTTP; Tue, 13 Sep 2016 13:10:24 -0700 (PDT) In-Reply-To: <7bf5cd37-6436-8cec-74e3-f0856bcc807c@openmailbox.org> References: <7bf5cd37-6436-8cec-74e3-f0856bcc807c@openmailbox.org> From: Cedric Blancher Date: Tue, 13 Sep 2016 22:10:24 +0200 Message-ID: Subject: Re: What is the point in expression: !!var ? To: twilight Cc: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Sep 2016 20:10:25 -0000 The point is to transform the value of a (any kind, like pointer) to a Boolean value. Ancient C trick, goes back to dmr Ced On 13 September 2016 at 21:54, twilight wrote: > Hello, > > I'm digging through FreeBSD cppcheck scan report with hope to catch some > bugs. > > I've came along a line: > c = cond(token, val, yylex(), noeval | !!a); > > What's the point in using !! twice? Can it be deleted? > Here is the context: > > static arith_t cond(int token, union yystype *val, int op, int noeval) > { > arith_t a = or(token, val, op, noeval); > arith_t b; > arith_t c; > > if (last_token != ARITH_QMARK) > return a; > > b = assignment(yylex(), noeval | !a); > > if (last_token != ARITH_COLON) > yyerror("expecting ':'"); > > token = yylex(); > *val = yylval; > > c = cond(token, val, yylex(), noeval | !!a); > > return a ? b : c; > } > > > -- > Cheers~ > > PGP key fingerprint: > 07B3 2177 3E27 BF41 DC65 CC95 BDA8 88F1 E9F9 CEEF > > You can retrieve my public key at pgp.mit.edu. > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" -- Cedric Blancher [https://plus.google.com/u/0/+CedricBlancher/] Institute Pasteur