Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1168281imc; Mon, 11 Mar 2019 07:54:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxewI1AwBT4rGXzcNbp8SulkfvF8bxRwNkoasU9OU8lYk7x848IcO+HSZHTO+UBbcrc/3Sg X-Received: by 2002:a62:788a:: with SMTP id t132mr33734245pfc.101.1552316045327; Mon, 11 Mar 2019 07:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552316045; cv=none; d=google.com; s=arc-20160816; b=D9/JbjVm0r3N9w3IkVLcA7kH+HOSHDnM8seNJxb2GbLJp91tjgFwIKc4iSM7JbdOua fV95JWJrqXLu1dP3jcGU+aX9psXtKJZru2y/NNvLW3dmHQ/01guz040YlT/6KI3vFonJ MklEHfa2SmNiw6hfzhZlFx/SRfgJC1RW4Mj/HEmPXux5DUr2EtY6wzPKiQv1EG30ifZ/ SEJ5RtFNz8rBNA98NDX/eSaOEFGvu3KwX1fo7oZBQxFbO2LZax8vo1DbYDIcDJRPAjjq WzjUaGY6G5tj02XF/W2qBrfIBa9MleD8YfuwBrC9PcDPhnMSC9ohkJz+8eA8bw1cWXoi oUqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Pp0hqpqjCslrSXAn8lZXFgNmAVElhkqozU+LNwwYcoc=; b=HxC/vb03tpGyXOeN7RrWQAkzFEo3bywLHgyLpvF4xw8MyaDh+SqxiIgH3Qqt1cR+hf WfAJy89vyZ7hZzCf/F4uoAexi/3cRYLufolxLwR2y02rjC3Z4O9jjK5piYEDyDiX32cw u9N33AvIih/xokVnN1nw4AKdXdb6igTgPZiPZ+HZ90/b3n9+QD1YhZwpAPZjSyL7NYFi lrK/S4GvPwT4eY+IO6Og3sfsBUuuNJP9Bl+j0Xskg1i8n1jVBWwZvTBRmsB2ckxL8UYb 8fd3QMuRlnUffW9/k6lDzzDhPBPqXywuC18p6zh+sZaOAlIDxUy6u6+k5cuA9ai6obwx oNHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@azazel.net header.s=20190108 header.b=QNiVP2pU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=REJECT dis=NONE) header.from=azazel.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q207si5085254pgq.321.2019.03.11.07.53.49; Mon, 11 Mar 2019 07:54:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@azazel.net header.s=20190108 header.b=QNiVP2pU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=REJECT dis=NONE) header.from=azazel.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727643AbfCKOxW (ORCPT + 99 others); Mon, 11 Mar 2019 10:53:22 -0400 Received: from kadath.azazel.net ([81.187.231.250]:55112 "EHLO kadath.azazel.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbfCKOxW (ORCPT ); Mon, 11 Mar 2019 10:53:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=azazel.net; s=20190108; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Pp0hqpqjCslrSXAn8lZXFgNmAVElhkqozU+LNwwYcoc=; b=QNiVP2pUTlSijwO1C4VrvXh9GG viAE6J/OkOfgOJPMj52jzrhOQURsOKpePd7dDa35h5wwKuyol06DyuVsasCwrsnkf1UwNeALpBcmj o4NqzWpw/Q36o9bR0eItIUfDk6S4oxuY8l1HriccPPrK5mGuHCYEiTU/H3MTWknEAWvTt0QhTNFBq 5RapNy8jAKyqzXSLARg7cCzufXpciqGq/F7/onbQRN8cMOtkZlZh7cbFiDOeQfm5AgeqHtvNfshOh aCXsERW3FXbXZFgQTORyTXpuNqiJqWT3K3feRSng3XULbuZZN12RbIOWGGA3Usv4z8T2BPLZo0MbD fnypGHXA==; Received: from kadath.azazel.net ([2001:8b0:135f:bcd1:e2cb:4eff:fedf:e608] helo=azazel.net) by kadath.azazel.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h3MID-0003PK-TU; Mon, 11 Mar 2019 14:52:41 +0000 Date: Mon, 11 Mar 2019 14:52:40 +0000 From: Jeremy Sowden To: Kalle Valo Cc: ga58taw@mytum.de, Julius Niedworok , linux-wireless@vger.kernel.org, david@redhat.com, nc@net.in.tum.de, Johannes Berg , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC v2] mac80211: debugfs option to force TX status frames Message-ID: <20190311145240.akms2pz2hxsalmaz@azazel.net> References: <20190306200206.60916-1-julius.n@gmx.net> <87k1hazo6r.fsf@purkki.adurom.net> <20190307193045.a7awwn6mycloccq5@mission-control> <87h8c98q4l.fsf@codeaurora.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4jlle5knlvfploax" Content-Disposition: inline In-Reply-To: <87h8c98q4l.fsf@codeaurora.org> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:8b0:135f:bcd1:e2cb:4eff:fedf:e608 X-SA-Exim-Mail-From: jeremy@azazel.net X-SA-Exim-Scanned: No (on kadath.azazel.net); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --4jlle5knlvfploax Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2019-03-11, at 16:03:38 +0200, Kalle Valo wrote: > ga58taw@mytum.de writes: > > On Thu, Mar 07, 2019 at 05:42:04PM +0200, Kalle Valo wrote: > > > > + len = scnprintf(buf, sizeof(buf), "%d\n", > > > > (int)local->force_tx_status); > > > > > > I wonder about the cast, is it guaranteed that a bool is always of > > > the same size as an int? > > > > Why is this a problem? If a bool is smaller than an int, the > > compiler emits code that will prepend the value of force_tx_status > > with zeros. > > Let's say that a bool is a byte and int is four bytes. If you use "%d" > I would guess that in that case scnprintf() writes 4 bytes, meaning > that 3 bytes will be overwriting either padding or some other field in > the struct. It's the value that matters, not the type. It will only be too big for the buffer if the result of casting local->force_tx_status to int is less than -9 or greeater than 99. scnprintf(buf, size(buf), "%lld\n", (long long)local->force_tx_status) would also be fine if the value were in range. Note also that scnprintf will not overrun the buffer: it will truncate the string. > But I'm no compiler expert so I'm not going to argue about this > anymore. I just wanted to point out that that the cast looks > dangerous and I would not do it. As it happens, arguments to variadic functions are subject to the "default argument promotions," so if local->force_tx_status is in fact a bool (I can't find the definition), it would be promoted to int and the cast is superfluous. J. --4jlle5knlvfploax Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZ8d+2N/NBLDbUxIF0Z7UzfnX9sMFAlyGdjcACgkQ0Z7UzfnX 9sMb1BAAsSESto65kU2vMM1odmXXphdjm3eCo+b7dJE6rHaaAB1IzY16XAGv1R1A T7vVvm+5Ia1WFFnKNr8VnF1s4gIhzqPCAGqHSuERNyIQKcAAwSVtSZtHpGa+WjrD qs/gfLXh7AkXQAePZG7p+KIvFVYa4ty94YonfEOE4MQlayUz1TdgwWnXezCk5i7d 89H/rcZbcSQ9osp3+qIDoOGLvZa+nKLCIOrD85LTpfDpYUC3lUetM1byPsudv+5A HW7TGsbKOBnQLeIPx1o1DZUt0OX7pqlyrsO6K0XkBJHvGTFInP6MRenpDDPswXPn O8JxtqJ2mwEKj0HKoInopvXesPYY5NrHqML6PlzY3O9j1Wd5rviA6r80Y4MW06kd fQMoSKhK9nF6nNviaEXNmXCteryPlQTdAm5L05VmK2wiUJcza+ntF4yN6nEryq0a kd17nFUl+LU0LliCRxFpLSBV6F31s26rUVy9BEqp3q74Yh7Sqg5l5N0ZHInrEc2D XtJaTf5Nbyh7LHKiiiOpNMPzOD0pxixkmF8HU/2XW34uLl6ojXgvyiSE0EXrYdOM AjN5dEtxFpnM1dv7cQDoHdNTqYpcDLnstcXuyHcWru4bTXXcrPrVok/tbnsQ5x5m 6Nlqd5G0pK0e2nigrCqBmigZxIPv4AVPRgDrlA/Sik96A9tbsq8= =KvZy -----END PGP SIGNATURE----- --4jlle5knlvfploax--