Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp551664ybh; Sun, 12 Jul 2020 15:23:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuUNVB7li/KtY7kp7KGxbQz/NnqqvV5AtjxH9svOCDEnh4cLSrDnLoNzvdeB1iv1XMg6Lu X-Received: by 2002:a50:e8c9:: with SMTP id l9mr80783774edn.272.1594592595083; Sun, 12 Jul 2020 15:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594592595; cv=none; d=google.com; s=arc-20160816; b=t6tzmWInyrAh6S9JvnqOq7Iv0HUqan3XUxXvbRiULKSwkH8snSrxE0iKXJg3vU26hY tXnG8io3Xoq/xu+IfH13yPZetPS1z0QJmyyl/Oe+LQnPnGy/AAfzHcDVmZU2KkP/AJq2 Xj39ZIXycmaK/sKwN/eO1jXDk2+ag+STN0uFeQs70rPMnjYMHQ8Y430ii+cLn3Hc9TPc VTB+KZvKocKDVDR9RE6pXdXLh+OJRK/1N9C4zFjZIL3JNW6HXj4WghTg5E873o12GypL RcTKHFFvuh0R5rJUGayJO5zNovxCE11pkou1HnB/8eo/SaGtHtXfWNamNk1k/P4IEazC rcGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:dkim-signature:dkim-filter; bh=WWKmCXEzzN81kjVxRxEwWLBIb6cLUKLjvr1yWSka0hk=; b=OiG0HRMbwJabsJ2fyxj3SKBLF701npGSNhF+PRk9RNj6QI04OXMyARpRZwhdFJ88EJ KVBzxe1SikbQq2eG39tVxQD/2l+8YJvj/gEYkdAIEMVSs1kLVs4CctpQ4c4iCcNs03vy QcgqLSLSg5RcbjylcqX3CjijhWKkJ8PJMxVt9kjCzfuKFXzd2sXrXQyNo1tbPn+XiBwC 5wOLDKoUKt2YYOSc/XlHjI9SCw1MMOFXU9d6ecyrIzywZ3U7quY1SAgVWdeg2FYgSwts 0U5zJwCLZRuKCqvW88mw6/3p9lm8pAB9KzQYsFaMM3HsMJGqGJNQXPiSaZuwqOr5UDB8 ws7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@zytor.com header.s=2020062301 header.b=bcwnj142; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds17si10188298ejc.619.2020.07.12.15.22.49; Sun, 12 Jul 2020 15:23:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@zytor.com header.s=2020062301 header.b=bcwnj142; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727919AbgGLWWM (ORCPT + 99 others); Sun, 12 Jul 2020 18:22:12 -0400 Received: from terminus.zytor.com ([198.137.202.136]:53929 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727785AbgGLWWM (ORCPT ); Sun, 12 Jul 2020 18:22:12 -0400 Received: from [IPv6:2601:646:8600:3281:dcc1:f8b3:2766:5f92] ([IPv6:2601:646:8600:3281:dcc1:f8b3:2766:5f92]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id 06CMLw9F1257107 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Sun, 12 Jul 2020 15:22:01 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 06CMLw9F1257107 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2020062301; t=1594592521; bh=WWKmCXEzzN81kjVxRxEwWLBIb6cLUKLjvr1yWSka0hk=; h=Date:In-Reply-To:References:Subject:To:CC:From:From; b=bcwnj1420wmcaI8tKWrcHgo343qrpzxx3bRpqON9zxrrk6ndmy9hI49v+fMt7t1G5 fwlXdbUlUP7ee8HpiFnlSrL/8KIir2AMF7gK3w9RkojES6ZYmkLKMqjhLwFnjE0mDR Hqaf4qry1Ycm5KZkh6pBqCUabSmGEsCxrH3RUNmwn7O6lYG+1XXiFyyvLqGdtbknLN GudePfkmj2y0j7CsxReL+PdIhSItoR8WaxAQL0BOndfFpJiubVnB0I7U1meObJ26e/ dfUCRBn6SVs7EeNpaoEfTdGM5AIDg34IXKs1g3D2Abt0o1lnIo433pVL7bthJ+QgR5 hJaBXbIoTmbxA== Date: Sun, 12 Jul 2020 15:21:49 -0700 User-Agent: K-9 Mail for Android In-Reply-To: <9af191c2-0f2c-7637-433a-b557a07590ca@redhat.com> References: <20200712125952.8809-1-trix@redhat.com> <639c8ef5-2755-7172-fbb8-ce45c8637feb@zytor.com> <9af191c2-0f2c-7637-433a-b557a07590ca@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] decompress_bunzip2: fix sizeof type in start_bunzip To: Tom Rix , alain@knaff.lu CC: linux-kernel@vger.kernel.org, stable@vger.kernel.org From: hpa@zytor.com Message-ID: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On July 12, 2020 8:12:43 AM PDT, Tom Rix wrote: > >On 7/12/20 6:09 AM, H=2E Peter Anvin wrote: >> On 2020-07-12 05:59, trix@redhat=2Ecom wrote: >>> From: Tom Rix >>> >>> clang static analysis flags this error >>> >>> lib/decompress_bunzip2=2Ec:671:13: warning: Result of 'malloc' is >converted >>> to a pointer of type 'unsigned int', which is incompatible with >sizeof >>> operand type 'int' [unix=2EMallocSizeof] >>> bd->dbuf =3D large_malloc(bd->dbufSize * sizeof(int)); >>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> >>> Reviewing the bunzip_data structure, the element dbuf is type >>> >>> /* Intermediate buffer and its size (in bytes) */ >>> unsigned int *dbuf, dbufSize; >>> >>> So change the type in sizeof to 'unsigned int' >>> >> You must be kidding=2E >> >> If you want to change it, change it to sizeof(bd->dbuf) instead, but >this flag >> is at least in my opinion a total joke=2E For sizeof(int) !=3D >sizeof(unsigned >> int) is beyond bizarre, no matter how stupid the platform=2E > >Using the actual type is more correct that using a type of the same >size=2E > >trix > >> -hpa >> "More correct?" All it is is more verbose=2E Using the sizeof of the actual object at least adds some actual safety=2E --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E