From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 115DFC433EF for ; Tue, 12 Oct 2021 07:01:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8F9166109E for ; Tue, 12 Oct 2021 07:01:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F9166109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 28C4A900002; Tue, 12 Oct 2021 03:01:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23C746B0071; Tue, 12 Oct 2021 03:01:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10404900002; Tue, 12 Oct 2021 03:01:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id 0168D6B006C for ; Tue, 12 Oct 2021 03:01:34 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A698F82499A8 for ; Tue, 12 Oct 2021 07:01:34 +0000 (UTC) X-FDA: 78686889708.27.FFC96B1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 42B09F0020C2 for ; Tue, 12 Oct 2021 07:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634022093; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JcxrlQUjq8xG8UjdON0+Dxic3MPMUmRwzuZ5LLezMSM=; b=Or9BG3DFuI9yT/Fepwa9K/awRj3J5ORR34B4VzNDy9Ena9Wm8VzCV+8iDiXIpdxa/Zb0BO miTjVXcdnSisZczfFHXH4O1Y1e4rtQt1lvz83s+IiZiPb3JcCUqequjDjO3B8HOXNlMDb6 66Z0lYXm05y9J5Z/JWtGJXTy4GBe0uA= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-221-PQMfdILkMe-orRDRD2ngow-1; Tue, 12 Oct 2021 03:01:32 -0400 X-MC-Unique: PQMfdILkMe-orRDRD2ngow-1 Received: by mail-wr1-f69.google.com with SMTP id c2-20020adfa302000000b0015e4260febdso14940423wrb.20 for ; Tue, 12 Oct 2021 00:01:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=JcxrlQUjq8xG8UjdON0+Dxic3MPMUmRwzuZ5LLezMSM=; b=vxKTHfn5U9OAk9+KlK/+xjyCSAlbzli+QY6XKxHuAKJf+933L4UV488EoTEqv2yCoy okSMGzpLqo6xK0emCKewq7xvkerv5NzgjSqXkNxYd1YHCakSekjKZmXVOIhxpI0X9CWa 3X5BHAZVUWxf+klUvw84OXvGyoWCNcmjncN1olBX2MlVcfs+Ltl6W3D0zESDil4xG/0l k4G8MCbdoQ6Ux39MEtarqb8NYAAczvovDEs2vne9FfF4G2+ikAodR1ZPw3b2jCnRDhEj OV1O5CiY+Ji8Im85bxwYYr4MO/McsC5DBmBq+MuGgSHd+LdRZrAFMoj75CHpm0UFWSZE +UrQ== X-Gm-Message-State: AOAM530wxP1G88r2DSRwUvxJuz6zw5NPEl7OdXpnyMb2xawFFGZMsyqG BXLb8hB6yHf9/tTZXbo9SS1lIXaiAfbQQCzs36yKfuruqPApEXZ0D6pBfnrLf6pcMLUPrPPHCAs 8xUSu8ZHGPVY= X-Received: by 2002:a05:6000:1289:: with SMTP id f9mr5574660wrx.192.1634022091399; Tue, 12 Oct 2021 00:01:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXA3U+5ahCYPei3Bm6Mik/omjluNny8a69EmIkoT8VpaGZsKzd7/MpKs8SD1TjSeBkDCKxBw== X-Received: by 2002:a05:6000:1289:: with SMTP id f9mr5574637wrx.192.1634022091169; Tue, 12 Oct 2021 00:01:31 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6a12.dip0.t-ipconnect.de. [91.12.106.18]) by smtp.gmail.com with ESMTPSA id r9sm9403871wru.2.2021.10.12.00.01.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Oct 2021 00:01:30 -0700 (PDT) Subject: Re: [PATCH] Fix application of sizeof to pointer To: davidcomponentone@gmail.com, akpm@linux-foundation.org Cc: shuah@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Zeal Robot References: <20211012030116.184027-1-davidcomponentone@gmail.com> From: David Hildenbrand Organization: Red Hat Message-ID: <3ee52f17-0357-a99a-352e-424bfcc07f27@redhat.com> Date: Tue, 12 Oct 2021 09:01:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20211012030116.184027-1-davidcomponentone@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 42B09F0020C2 X-Stat-Signature: gewf7okg9d8bz49opd8h7fkps4uergjc Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Or9BG3DF; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1634022094-828453 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 12.10.21 05:01, davidcomponentone@gmail.com wrote: > From: David Yang > > The coccinelle check report: > "./tools/testing/selftests/vm/split_huge_page_test.c:344:36-42: > ERROR: application of sizeof to pointer" > Using the "strlen" to fix it. > > Reported-by: Zeal Robot > Signed-off-by: David Yang > --- > tools/testing/selftests/vm/split_huge_page_test.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/vm/split_huge_page_test.c b/tools/testing/selftests/vm/split_huge_page_test.c > index 1af16d2c2a0a..52497b7b9f1d 100644 > --- a/tools/testing/selftests/vm/split_huge_page_test.c > +++ b/tools/testing/selftests/vm/split_huge_page_test.c > @@ -341,7 +341,7 @@ void split_file_backed_thp(void) > } > > /* write something to the file, so a file-backed THP can be allocated */ > - num_written = write(fd, tmpfs_loc, sizeof(tmpfs_loc)); > + num_written = write(fd, tmpfs_loc, strlen(tmpfs_loc) + 1); > close(fd); > > if (num_written < 1) { > I think the code really just wants to write anything to the file that will be >= 1, which is also the case with this weird usage of sizeof. As an alternative, I think we can just write anything else to the file num_written = write(fd, (void *)&fd, sizeof(fd)); or num_written = write(fd, "1", 1); If I am not wrong/ -- Thanks, David / dhildenb