From: "Michael S. Tsirkin" <mst@redhat.com>
To: Harald Mommer <harald.mommer@oss.qualcomm.com>
Cc: Francesco Valla <francesco@valla.it>,
Matias Ezequiel Vara Larsen <mvaralar@redhat.com>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol@kernel.org>,
Mikhail Golubev-Ciuchea
<mikhail.golubev-ciuchea@oss.qualcomm.com>,
Jason Wang <jasowang@redhat.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
linux-can@vger.kernel.org, virtualization@lists.linux.dev,
Wolfgang Grandegger <wg@grandegger.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>
Subject: Re: [PATCH v7] can: virtio: Add virtio CAN driver
Date: Tue, 3 Feb 2026 07:05:15 -0500 [thread overview]
Message-ID: <20260203070338-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <eec1a83b-e36f-47bb-9a5b-6888b42e063a@oss.qualcomm.com>
On Tue, Feb 03, 2026 at 12:55:07PM +0100, Harald Mommer wrote:
>
>
> On 1/9/26 18:23, Francesco Valla wrote:
> >> +static u8 virtio_can_send_ctrl_msg(struct net_device *ndev, u16 msg_type)
> >> +{
> >> + struct scatterlist sg_out, sg_in, *sgs[2] = { &sg_out, &sg_in };
> >> + struct virtio_can_priv *priv = netdev_priv(ndev);
> >> + struct device *dev = &priv->vdev->dev;
> >> + struct virtqueue *vq;
> >> + unsigned int len;
> >> + int err;
> >> +
> >> + vq = priv->vqs[VIRTIO_CAN_QUEUE_CONTROL];
> > Nit: consider initializing this above, while declaring it.
>
> All those "Nit" regarding initialization cause problems. There is a reason why it was done the way it is.
>
> The network people require that the declaration lines are ordered by line length. longest line first. This is called "Reverse Christmas tree". Don't ask me why, this formatting style is what the network people require. Their subsystem, their rules.
>
> To initialize the vq you need now already the priv initialized. If now the vq line becomes longer than the priv line you will violate the special formatting requirements of the network subsystem.
>
> Solution was: What you see above.
>
> Regards
> Harald
So you reorder it then:
struct scatterlist sg_out, sg_in, *sgs[2] = { &sg_out, &sg_in };
struct virtqueue *vq = priv->vqs[VIRTIO_CAN_QUEUE_CONTROL];
struct virtio_can_priv *priv = netdev_priv(ndev);
struct device *dev = &priv->vdev->dev;
unsigned int len;
int err;
and where is the problem?
On the flip size, this guarantees we will not forget to initialize.
--
MST
next prev parent reply other threads:[~2026-02-03 12:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 18:44 [PATCH v7] can: virtio: Add virtio CAN driver Matias Ezequiel Vara Larsen
2026-01-09 17:23 ` Francesco Valla
2026-01-12 16:48 ` Matias Ezequiel Vara Larsen
2026-02-03 11:55 ` Harald Mommer
2026-02-03 12:05 ` Michael S. Tsirkin [this message]
2026-02-03 12:32 ` Vincent Mailhol
2026-02-03 12:49 ` Michael S. Tsirkin
2026-02-03 15:18 ` Harald Mommer
2026-02-03 16:20 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260203070338-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=francesco@valla.it \
--cc=harald.mommer@oss.qualcomm.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mikhail.golubev-ciuchea@oss.qualcomm.com \
--cc=mkl@pengutronix.de \
--cc=mvaralar@redhat.com \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=wg@grandegger.com \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox