Message ID | 20230215130605.31583-6-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp180720wrn; Wed, 15 Feb 2023 05:09:51 -0800 (PST) X-Google-Smtp-Source: AK7set90FTLkOS276Mx6hDnGKColoMHx9St1r3Y4xBXcimObfVnRAqDcU+bFLKp0C79KUBAOdRq1 X-Received: by 2002:a17:903:2312:b0:19a:9705:6465 with SMTP id d18-20020a170903231200b0019a97056465mr2821202plh.37.1676466591412; Wed, 15 Feb 2023 05:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676466591; cv=none; d=google.com; s=arc-20160816; b=Y/zroOpFc9UAZxTl6SvJhWlC+V6Fl5y43PqwYf91xizbrDTbl3pMp4pIfLpg8tu5pJ l2vb73WFhoFDcZM7t9H8Wtfn5hFLKj4lq9yyvTcufhNUNThqIYG3Bb3Qk24Kixkwb0Fm LCU3dbRvL3LbcCXU6on2F601ZYy2yUiuErDazhTr6+MSBCFRvRVqJnrSv9MseWJfK2WR N++yAyaSJluNoxEUIQnAVB5h+BKg2aPBZI9IMarlDTq95u2lSw71mkEEOks/0xFbCWN/ D0l35ZCb5ShkFEDH1XFemdtSNcCDbRM/AvoZ5wBOkdzAlk6Iu1Tx5ycp0m2MnG1PSBbV cMyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=skKIHCCIebwrJCro4tB01evkb/lLhYBdD6Ous1zfb4k=; b=z9kvJTIOsGY53sK9YWDhyeHERDPOPSJDAUHEY2BZ1B7Y9G7BwfE+IPxMUjsYZvNAGx Zv9wTQR916MJkoNkm4z/ni+/wpw4w3MyvV5mRSx+3xWtCYuQ84JsfRQiBwIMvYkUX1X7 t+HG7vI/ZnnMhe/5ZT4v8bBG8vbkF7ip6iIyWSEEFL5JStP4qVAzk2m9vAdIEMsjReW8 o+Gib4LfawWr+qLd3DvIEv6jQPcqIEzMREXeQ8idBJQ1lYRq8iY3vVVmP+szcI9azaQJ QeuDQA8Qj+Ub7nB79FykobcSAf0/8t1z9EMExue0RamJ9CK6jOqxkhdaMWKKKU+gpdvd UUGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TbpsbkpI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a170902d38200b0019468fe44d5si14069948pld.233.2023.02.15.05.09.37; Wed, 15 Feb 2023 05:09:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TbpsbkpI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234088AbjBONGz (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Wed, 15 Feb 2023 08:06:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234117AbjBONGn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Feb 2023 08:06:43 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54C1F38E81; Wed, 15 Feb 2023 05:06:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676466396; x=1708002396; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ATWdTIj6nlHosfxRj2cQEQ4dZAgek4AbNN/n59hIx9E=; b=TbpsbkpIrsubjjxbWHiTBvoESEjnbU4eSJ1VO4a7FwvPx9sQMkzsyJgn KOfl3aCvk1wtQX2lzcD0ERrQR3FhvHN+oc3U090cqCRDmxW9CMyWndz2U dhF6NAgjdxiFju1ftEj1GSSmKMWLwtuQsIg7kJYuAusNL+YNgbCm1GHcA AzvA1X/XTDUPa3aocRkXHRTx+LWE7OPSKoacyzUclPfv542ReQoXhb+ul jraNiX886Fwb36ItGkDjHQ0yGBbBlTZlZyzi96C8nUdsyfDVV2IEGaeUG YzRaoaVxDM9WN/q3wGth++vHWheSnoZI+mFOxMw4kzHZNhc6Wz10cstmo A==; X-IronPort-AV: E=McAfee;i="6500,9779,10621"; a="319456280" X-IronPort-AV: E=Sophos;i="5.97,299,1669104000"; d="scan'208";a="319456280" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2023 05:06:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10621"; a="812436072" X-IronPort-AV: E=Sophos;i="5.97,299,1669104000"; d="scan'208";a="812436072" Received: from hshannan-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.49.120]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2023 05:06:33 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre <reinette.chatre@intel.com>, Fenghua Yu <fenghua.yu@intel.com>, Shuah Khan <shuah@kernel.org> Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> Subject: [PATCH v2 5/9] selftests/resctrl: Replace obsolete memalign() with posix_memalign() Date: Wed, 15 Feb 2023 15:06:01 +0200 Message-Id: <20230215130605.31583-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230215130605.31583-1-ilpo.jarvinen@linux.intel.com> References: <20230215130605.31583-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757902632822052541?= X-GMAIL-MSGID: =?utf-8?q?1757902632822052541?= |
Series |
selftests/resctrl: Fixes to error handling logic and cleanups
|
|
Commit Message
Ilpo Järvinen
Feb. 15, 2023, 1:06 p.m. UTC
memalign() is obsolete according to its manpage.
Replace memalign() with posix_memalign() and remove malloc.h include
that was there for memalign().
As a pointer is passed into posix_memalign(), initialize *p to NULL
to silence a warning about the function's return value being used as
uninitialized (which is not valid anyway because the error is properly
checked before p is returned).
Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
tools/testing/selftests/resctrl/fill_buf.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Comments
Hi Ilpo, On 2/15/2023 5:06 AM, Ilpo Järvinen wrote: > memalign() is obsolete according to its manpage. > > Replace memalign() with posix_memalign() and remove malloc.h include > that was there for memalign(). > > As a pointer is passed into posix_memalign(), initialize *p to NULL > to silence a warning about the function's return value being used as > uninitialized (which is not valid anyway because the error is properly > checked before p is returned). > > Suggested-by: Reinette Chatre <reinette.chatre@intel.com> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > --- Thank you Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reinette
diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index c20d0a7ecbe6..3cd0b337eae5 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -14,7 +14,6 @@ #include <sys/types.h> #include <sys/wait.h> #include <inttypes.h> -#include <malloc.h> #include <string.h> #include "resctrl.h" @@ -64,11 +63,13 @@ static void mem_flush(void *p, size_t s) static void *malloc_and_init_memory(size_t s) { + void *p = NULL; uint64_t *p64; size_t s64; + int ret; - void *p = memalign(PAGE_SIZE, s); - if (!p) + ret = posix_memalign(&p, PAGE_SIZE, s); + if (ret < 0) return NULL; p64 = (uint64_t *)p;