From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 04D9A21E94615 for ; Wed, 20 Sep 2017 23:43:14 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 23:46:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,424,1500966000"; d="scan'208";a="154331006" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga006.fm.intel.com with ESMTP; 20 Sep 2017 23:46:19 -0700 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Steven Shi , Michael Kinney , Liming Gao , Star Zeng , Eric Dong , Fu Siyuan , Ye Ting , Wu Jiaxin , Qin Long , Paolo Bonzini Date: Thu, 21 Sep 2017 14:46:11 +0800 Message-Id: <20170921064617.2628-1-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 Subject: [PATCH v2 0/6] Resolve undefined behaviours in left shift OPs X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Sep 2017 06:43:15 -0000 According to the feebacks from Paolo, the following changes are made in this version of patch series: a. Refine the code logic in Tpl.c to void left shifting the negative value. Also makes the code more readable; b. Remove the '~' operator before 'Time.Hour' in DxeNetLib.c, since it seems like an implementation choice for generating the seed; c. Use '1U' instead of '(UINT32)1' in Crc32.c. V1 history: The series resolves two kinds of undefined behaviours in left shift operations: a. Left-shifting negative values; b. Left-shifting that incurs the result being out of range. Cc: Steven Shi Cc: Michael Kinney Cc: Liming Gao Cc: Star Zeng Cc: Eric Dong Cc: Fu Siyuan Cc: Ye Ting Cc: Wu Jiaxin Cc: Qin Long Cc: Paolo Bonzini Hao Wu (6): MdePkg/PrintLib: Fix possible negative value left shift MdeModulePkg/PrintLib: Fix possible negative value left shift MdeModulePkg/Tpl: Fix negative value left shift MdeModulePkg/DxeNetLib: Fix negative value left shift MdeModulePkg/Crc32: Fix possible out of range left shift MdeModulePkg/AtaAtapiPassThru: Fix possible out of range left shift MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 4 ++-- MdeModulePkg/Core/Dxe/Event/Tpl.c | 12 +++++++++--- MdeModulePkg/Core/RuntimeDxe/Crc32.c | 6 +++--- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 2 +- MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c | 2 +- MdePkg/Library/BasePrintLib/PrintLibInternal.c | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) -- 2.12.0.windows.1