From patchwork Mon Jun 22 16:21:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 11618373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A795C90 for ; Mon, 22 Jun 2020 16:21:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99F732076A for ; Mon, 22 Jun 2020 16:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729669AbgFVQVv (ORCPT ); Mon, 22 Jun 2020 12:21:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41290 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729519AbgFVQVt (ORCPT ); Mon, 22 Jun 2020 12:21:49 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05MG0fON017059 for ; Mon, 22 Jun 2020 12:21:49 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31tysprty0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 22 Jun 2020 12:21:49 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05MG0iFA017289 for ; Mon, 22 Jun 2020 12:21:48 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 31tysprtws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Jun 2020 12:21:48 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05MG1JhO029912; Mon, 22 Jun 2020 16:21:46 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma05fra.de.ibm.com with ESMTP id 31sa37seg8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Jun 2020 16:21:46 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05MGLifU61866298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Jun 2020 16:21:44 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41E875204E; Mon, 22 Jun 2020 16:21:44 +0000 (GMT) Received: from ibm-vm.ibmuc.com (unknown [9.145.9.197]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id E431652051; Mon, 22 Jun 2020 16:21:43 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org, pbonzini@redhat.com Cc: frankja@linux.ibm.com, thuth@redhat.com, david@redhat.com Subject: [kvm-unit-tests PATCH v1 7/8] lib/alloc_page: make get_order return unsigned int Date: Mon, 22 Jun 2020 18:21:40 +0200 Message-Id: <20200622162141.279716-8-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200622162141.279716-1-imbrenda@linux.ibm.com> References: <20200622162141.279716-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-22_09:2020-06-22,2020-06-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 mlxlogscore=904 mlxscore=0 lowpriorityscore=0 suspectscore=2 phishscore=0 clxscore=1015 cotscore=-2147483648 impostorscore=0 adultscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006220116 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Since get_order never returns a negative value, it makes sense to make it return an unsigned int. The returned value will be in practice always very small, a u8 would probably also do the trick. Signed-off-by: Claudio Imbrenda --- lib/alloc_page.h | 2 +- lib/alloc_page.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/alloc_page.h b/lib/alloc_page.h index e6a51d2..6181299 100644 --- a/lib/alloc_page.h +++ b/lib/alloc_page.h @@ -15,6 +15,6 @@ void *alloc_pages(unsigned long order); void free_page(void *page); void free_pages(void *mem, unsigned long size); void free_pages_by_order(void *mem, unsigned long order); -int get_order(size_t size); +unsigned int get_order(size_t size); #endif diff --git a/lib/alloc_page.c b/lib/alloc_page.c index 7c8461a..8769c3f 100644 --- a/lib/alloc_page.c +++ b/lib/alloc_page.c @@ -176,7 +176,7 @@ void page_alloc_ops_enable(void) alloc_ops = &page_alloc_ops; } -int get_order(size_t size) +unsigned int get_order(size_t size) { return is_power_of_2(size) ? fls(size) : fls(size) + 1; }