Stefan Hajnoczi
2021-Mar-23 08:34 UTC
[virtio-comment] Re: [RFC PATCH v1] virtio-vsock: use C style defines for constants
On Tue, Mar 23, 2021 at 09:18:34AM +0300, Arseny Krasnov wrote:> > On 22.03.2021 17:30, Stefan Hajnoczi wrote: > > On Mon, Mar 22, 2021 at 09:34:58AM -0400, Michael S. Tsirkin wrote: > >> On Mon, Mar 22, 2021 at 11:52:22AM +0000, Stefan Hajnoczi wrote: > >>> On Mon, Mar 22, 2021 at 09:37:59AM +0300, Arseny Krasnov wrote: > >>>> @@ -227,6 +226,11 @@ \subsubsection{Stream Sockets}\label{sec:Device Types / Socket Device / Device O > >>>> hints are permanent once sent and successive packets with bits clear do not > >>>> reset them. > >>>> > >>>> +\begin{lstlisting} > >>>> +#define VIRTIO_VSOCK_SHUTDOWN_RECEIVE_BIT 0 > >>>> +#define VIRTIO_VSOCK_SHUTDOWN_SEND_BIT 1 > >>>> +\end{lstlisting} > >>> The spec has no other _BIT constants. > >> True. Sometimes there's an _F_ somewhere there instead. > > You're right, I missed the virtio-net bit constants: > > > > #define VIRTIO_NET_F_GUEST_TSO4 7 > > > > Compared to: > > > > #define VIRTQ_DESC_F_AVAIL (1 << 7) > > > > or > > > > #define VIRTQ_DESC_F_WRITE 2 > > > > It's an inconsistent mix :). Hard to tell them apart when they aren't > > bitmask constants with '<<'. > > > > Can we use '<<' for clarity on new constants? > > So for bit constants, i can use: > > #define VIRTIO_VSOCK_SHUTDOWN_RECEIVE (1 << 0) > #define VIRTIO_VSOCK_SHUTDOWN_SEND (1 << 1) > > for this case and all other next cases, when i'll add SEQPACKET > description in spec?Personally I think that's clearest. Michael pointed out that the spec is not consistent though, so I won't complain if you prefer to keep the _BIT numbering. Stefan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20210323/69cfdb2a/attachment.sig>