From owner-svn-src-head@freebsd.org Thu Jun 22 23:38:18 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 1FF56D96D9E; Thu, 22 Jun 2017 23:38:18 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-pg0-f41.google.com (mail-pg0-f41.google.com [74.125.83.41]) (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 E0EE16AF1D; Thu, 22 Jun 2017 23:38:17 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-pg0-f41.google.com with SMTP id 132so14067354pgb.2; Thu, 22 Jun 2017 16:38:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=5yukiJqZGdIIMTuuWvNC9Is5l+tRYclOlGE5qU2ebEc=; b=H+bbZ7LMy3vNjePTw3rrrBj3g0nSxt+9r3BBQKk+6fK9lL+9b36CejTc2SJmsLDhv0 GdJ+fqjryPED55w7rE0l0PYJMZgdYhtj9LqAE1+QC2fhmkIz0av9jGpB63HwGQkWmjv6 l/gW/PwBGnPNYwcN/bt1TEDaMxoc8GWEM4Vxm5j/L38qsQ313xxDk5aURYUD4U3bVObz F8AbcAtfSPe0slNIRdefLNSEOPvTE7k3ai8Zihj0xE0P3Rm6hdylGWQe4j1C9CD+N7qM NxHtMuO3MFGkILUHfFi9YZR2brBOkuR/b+RDRVA5Sb91Jg6orEvVFa8lVa4Wgxih2cTp ZoXQ== X-Gm-Message-State: AKS2vOxQVXQV3e7Nw3jDsITNb8U4YIuRUNBuxS/zONjHLCkyMIjw1g+B 2VHpN7kJT86M/8DMTN106w== X-Received: by 10.101.91.138 with SMTP id i10mr5208497pgr.168.1498174696731; Thu, 22 Jun 2017 16:38:16 -0700 (PDT) Received: from mail-pg0-f42.google.com (mail-pg0-f42.google.com. [74.125.83.42]) by smtp.gmail.com with ESMTPSA id 18sm6142290pfo.92.2017.06.22.16.38.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 16:38:16 -0700 (PDT) Received: by mail-pg0-f42.google.com with SMTP id e187so14068005pgc.1; Thu, 22 Jun 2017 16:38:16 -0700 (PDT) X-Received: by 10.84.241.197 with SMTP id t5mr5638945plm.48.1498174696105; Thu, 22 Jun 2017 16:38:16 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.100.133.66 with HTTP; Thu, 22 Jun 2017 16:38:15 -0700 (PDT) In-Reply-To: <201610071257.u97CvZ3V029734@repo.freebsd.org> References: <201610071257.u97CvZ3V029734@repo.freebsd.org> From: Conrad Meyer Date: Thu, 22 Jun 2017 16:38:15 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r306806 - head/usr.bin/dtc To: Ed Maste Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, 22 Jun 2017 23:38:18 -0000 Hi Ed, I suspect this commit accidentally introduced a bug in define handling and was detected by Coverity as dead code (CID 1376409). On Fri, Oct 7, 2016 at 5:57 AM, Ed Maste wrote: > Author: emaste > Date: Fri Oct 7 12:57:35 2016 > New Revision: 306806 > URL: https://svnweb.freebsd.org/changeset/base/306806 > > Log: > Improvements to BSD-licensed DTC. > > - Numerous crash and bug fixes > - Improved warning and error messages > - Permit multiple labels on nodes and properties > - Fix node@address references > - Add support for /delete-node/ > - Consume whitespace after a node > - Read the next token before the second /memreserve/ > - Fix parsing of whitespace > - Clean up /delete-node/ and add support for /delete-property/ > - Handle /delete-node/ specifying a unit address > > Obtained from: https://github.com/davidchisnall/dtc @df5ede4 > > Modified: > head/usr.bin/dtc/checking.cc > head/usr.bin/dtc/checking.hh > head/usr.bin/dtc/dtb.cc > head/usr.bin/dtc/dtb.hh > head/usr.bin/dtc/dtc.1 > head/usr.bin/dtc/dtc.cc > head/usr.bin/dtc/fdt.cc > head/usr.bin/dtc/fdt.hh > head/usr.bin/dtc/input_buffer.cc > head/usr.bin/dtc/input_buffer.hh > head/usr.bin/dtc/string.cc > head/usr.bin/dtc/util.hh The original diff email was truncated, but this function was both moved from fdt.cc to input_buffer.cc and modified at the same time: fdt.cc: @@ -1169,87 +1327,10 @@ } } -bool -device_tree::parse_include(input_buffer &input, - const std::string &dir, - std::vector &roots, - FILE *depfile, - bool &read_header) -{ - if (!input.consume("/include/")) - { - return false; - } - bool reallyInclude =3D true; - if (input.consume("if ")) - { - input.next_token(); - string name =3D string::parse_property_name(input); - // XXX: Error handling - if (defines.find(name) =3D=3D defines.end()) - { - reallyInclude =3D false; - } - input.consume('/'); - } - input.next_token(); - if (!input.consume('"')) - { - input.parse_error("Expected quoted filename"); - valid =3D false; - return false; - } - int length =3D 0; - while (input[length] !=3D '"') length++; - - std::string file((const char*)input, length); - std::string include_file =3D dir + '/' + file; - input.consume(file.c_str()); - if (!reallyInclude) - { - input.consume('"'); - input.next_token(); - return true; - } ... input_buffer.cc: +void +text_input_buffer::handle_include() +{ + bool reallyInclude =3D true; + if (consume("if ")) + { + next_token(); + string name =3D parse_property_name(); + if (defines.count(name) > 0) + { + reallyInclude =3D true; + } + consume('/'); + } + next_token(); + if (!consume('"')) + { + parse_error("Expected quoted filename"); + return; + } + string file =3D parse_to('"'); + consume('"'); + if (!reallyInclude) + { + return; + } Note the use of the 'reallyInclude' sentinel. In the old function, it would be false if a "define" wasn't found in the "defines" lookup table, causing an early function return. In the new function, it is only ever initialized to true =E2=80=94 even if = the "define" isn't located in the global "defines" lookup table. Maybe the sense of the 'if (defines.count(name) > 0)' check and set should be inverted? Something like: if (defines.count(name) <=3D 0) reallyInclude =3D false; Best, Conrad