From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::441; helo=mail-wr1-x441.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 986A721179248 for ; Mon, 15 Oct 2018 23:20:13 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id 61-v6so23956140wrb.6 for ; Mon, 15 Oct 2018 23:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=3BDt4JMaPvTlae0/2QChCZfm+owVFr0IcitgTG165f8=; b=PQOgpB8hfOX4TtwyhvsHSsRivLIzd2P+d2rFxrwOOV1nNjMFYFtharuVGIB0reBEL4 XrN3AFTrkRTiYVxNl3djomEK0HXG6GwKSg/0LDgFhPOKU7tMAf1om9LhU9vz3r8VxBqq Q2geDk4IW8PSqi+HwFeYiJqRZ3JMoSLZ0JXx4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=3BDt4JMaPvTlae0/2QChCZfm+owVFr0IcitgTG165f8=; b=Aq/UjWvfqPi8aZO6H57oOJkhliFFCXpUswOTBOTjcuEEscu+LseCKgpguYw1uPgutt bZnEboK/o8QEvlxMCNdQ7U1h+TGkf3PHMG7pB4lHzm2Ud9bWuQKiGlz95kuY/uPtUOU5 fSAgkvpeKZToIZ7IeUvXHW4+OTHVmmYfVZlAhnsRFs6mZ7i/IT/V6HKZalQAJQXMLe6y jfYl/2yeNbwMB9bWmdPTNuNzeQ64SGQHbOxIPvlCxKXt/UCtKSvEu2Qz7csV6wGnCEnn tg8ecown93Zlpcly0X6m6Z0nOFTgmGUMYnFVUIdM98svKVOpAVIosVjpHWerukuW5x/I DDPA== X-Gm-Message-State: ABuFfoiBx19zZGOuxJIdTEU72UiSnicJEDGXJnGK6pY07cXwn97XMXgD XT7Q8WahjVEIGxOtTMCgsTic6A== X-Google-Smtp-Source: ACcGV63PLDOUG5Ha8HCTbuDkYieQTMGadkjJt+haieXtLdd3+HCz5urIZ8TkuVdVACtvApTQf+GidA== X-Received: by 2002:adf:ae41:: with SMTP id u1-v6mr16378246wrd.43.1539670811777; Mon, 15 Oct 2018 23:20:11 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 64-v6sm10916096wrr.64.2018.10.15.23.20.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 23:20:10 -0700 (PDT) Date: Tue, 16 Oct 2018 07:20:08 +0100 From: Leif Lindholm To: Hao Wu Cc: edk2-devel@lists.01.org, Star Zeng , Ruiyu Ni Message-ID: <20181016062008.tubfnsw3p6nbkew6@bivouac.eciton.net> References: <20181015045522.18732-1-hao.a.wu@intel.com> <20181015045522.18732-7-hao.a.wu@intel.com> MIME-Version: 1.0 In-Reply-To: <20181015045522.18732-7-hao.a.wu@intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH v1 6/7] MdeModulePkg/UdfDxe: Remove dead codes in FileName.c X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 06:20:14 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Oct 15, 2018 at 12:55:21PM +0800, Hao Wu wrote: > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1249 > > We found potential dead codes within File.c during the code coverage test. > > After manual review, we think the below ones are positive reports: > > A. In function MangleFileName(): > > FileName = TrimString (FileName); > // Begin of dead codes > if (*FileName == L'\0') { > goto Exit; > } > // End of dead codes > > When the code reaches the TrimString() call, the string in 'FileName' is > guaranteed to have a '\' character due to the call patterns of What in the call pattern guarantees this? Please be precise. > MangleFileName(). So after trimming the lead-off/tailing white spaces, > string in 'FileName' will not be an empty string. > > B. In function MangleFileName(): > > if (FileName[0] == L'.') { > if (FileName[1] == L'.') { > if (FileName[2] == L'\0') { > goto Exit; > } else { > FileName += 2; > } > } else if (FileName[1] == L'\0') { > goto Exit; > } > } > > When the code hits the above checks, string in 'FileName' will always have > a leading '\' character (denoting an absolute path) due to the call > patterns of MangleFileName(). So no leading '.' can be there in string > 'FileName'. What in the call pattern guarantees this? Please be precise. Regards, Leif