From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=cKPWAzrL; spf=pass (domain: linaro.org, ip: 209.85.166.193, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-it1-f193.google.com (mail-it1-f193.google.com [209.85.166.193]) by groups.io with SMTP; Mon, 22 Apr 2019 14:26:13 -0700 Received: by mail-it1-f193.google.com with SMTP id y10so20512854itc.1 for ; Mon, 22 Apr 2019 14:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O2b1qfLr5egSiCNHKwoqCX0yn7FTWHcN1DWgRjVwb0c=; b=cKPWAzrLfmG707m45KvnH0fk99rlYseV509DoP/NkNDu3I9WuMxawFdzBZl9ZPUqEN 1j26rRna20hsPdvSxPGJpPXnUJFw4AIpX+OS82Kbp3D6duV4YyNwhSkUBJeYPOcE8+Wm G6gMJtE4amN0aX2y3juUGJ1VEC1xr3jtvfRlPK3GmnS4Wjmv9TZCS7Yss1A6+0OTbwa4 I9LMOeVPfHyJikMEnG5c2EXQUeuoqXiTy6/tPKzxG2N2qBSblZuvsBd81UG9wmUnAPlb Ui29+vcviJjS8xClfHbw32wbqiHGugEPzF+p+7aJ09ErCtSwlxl6oQvZOFoTkAjYlFu8 zVpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O2b1qfLr5egSiCNHKwoqCX0yn7FTWHcN1DWgRjVwb0c=; b=hlyqfJcN4plLJxwS0VhOM68B31LImTK3DyYluX8Co1T+aEPrDIPsRywmekVDdm8PTW b+gyIlYYnUFjcT5k1J5YzIYil+OcnDr6P6icSelvCobbZAL2WIx7LxQWHBarbWoSeqgJ Alvzat7iMXZBJFxUDykR3Ik/F50Jbh7pX2xfaOmlAHVtkZxVvTbI5zEppgZyCCNKSGVN QKEPboyQtWhz19hzHdRHJnO5mSad6IQinG06rbB7RhlqAAX0YTphXdHELAgqX03+YJvj u7o4XNJ0bISI/bQMBffBRUAGL52QqalvV11ADyQkB0w5xoThrM9X/YSFff/KX3siUiDJ 1N+Q== X-Gm-Message-State: APjAAAUUx+uHngwSv1wUc73e99KLSi/k9BYiOTqhJeuUK1o7ZhI72KeY oAFWvztXY+U+Wz5aJxaION0bJwsiYuzFHXsA+f3xCg== X-Google-Smtp-Source: APXvYqxZMojowH1d1XT2JcZ9AlU6f1Lc09JBxkUnIVohYaVtMF7y8V3N5IyVo5FFcFrD4dRxPukCVWTDTY5zn1q0tLU= X-Received: by 2002:a24:59c1:: with SMTP id p184mr251954itb.158.1555968373005; Mon, 22 Apr 2019 14:26:13 -0700 (PDT) MIME-Version: 1.0 References: <20190422072447.10548-1-hao.a.wu@intel.com> In-Reply-To: From: "Ard Biesheuvel" Date: Mon, 22 Apr 2019 23:25:59 +0200 Message-ID: Subject: Re: [PATCH v1] MdeModulePkg/DxeCore: Please static checker for false report To: "Kinney, Michael D" Cc: "Wu, Hao A" , "devel@edk2.groups.io" , "Gao, Liming" , "Wang, Jian J" Content-Type: text/plain; charset="UTF-8" On Mon, 22 Apr 2019 at 16:41, Kinney, Michael D wrote: > > Hi Hao, > > I think a cleaner fix to this issues is replace both > ASSERT() statements with the following: > > if (EFI_ERROR (Status) || Entry->Emulator == NULL) { > FreePool (Entry); > continue; > } > > We do not expect the emulator protocol to disappear between > finding the handle and looking up the protocol instance, > but if it does, the handle can be skipped without ASSERT(). > > There are several examples of this style in DriverSupport.c. > > If we want to avoid the extra Allocate/Free in this error > condition, then a local variable can be added to get the > emulator protocol instance and only allocate an > EMULATOR_ENTRY if the emulator instance is successfully > found. > Is there any way we can #define the OUT modifier to something the static analyzer understands? (Which static analyzer is this btw?) Surely, we are not the only project dealing with pointers that are initialized by reference. Adding code to please the tools should really be the last resort imo.