lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Thu, 21 Apr 2022 19:05:50 +0800 From: "Zhu, Lingshan" <lingshan.zhu@...el.com> To: Zhou Furong <furong.zhou@...ux.intel.com>, jasowang@...hat.com, mst@...hat.com Cc: virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org Subject: Re: [PATCH] vDPA/ifcvf: allow userspace to suspend a queue On 4/12/2022 2:55 PM, Zhou Furong wrote: > Hi, > >> +bool ifcvf_get_vq_ready(struct ifcvf_hw *hw, u16 qid) >> +{ >> + struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; >> + bool queue_enable; >> + >> + vp_iowrite16(qid, &cfg->queue_select); >> + queue_enable = vp_ioread16(&cfg->queue_enable); >> + >> + return (bool)queue_enable; > queue_enable is bool, why cast? looks like remove the variable is better. > return vp_ioread16(&cfg->queue_enable); Hi, thanks for your comments. This cast tries to make some static checkers happy. Please correct me if I misunderstood it: vp_ioread16() returns an u16, and bool is not an one bit variable, it is C99 _Bool. C99 defines _Bool to be true(expends to int 1) or false(expends to int 0). I think this implies a bool is actually capable to store an u16. so I am afraid some checkers may complain about "queue_enable = vp_ioread16(&cfg->queue_enable);", a cast here can help us silence the checkers. see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf section 7.16 and https://www.kernel.org/doc/Documentation/process/coding-style.rst section 17 Thanks, Zhu Lingshan > >> static bool ifcvf_vdpa_get_vq_ready(struct vdpa_device *vdpa_dev, >> u16 qid) >> { >> struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); >> + bool ready; >> - return vf->vring[qid].ready; >> + ready = ifcvf_get_vq_ready(vf, qid); >> + >> + return ready; > remove ready looks better > return ifcvf_get_vq_ready(vf, qid); > > > Best regards, > Furong
Powered by blists - more mailing lists