Skip to content
Snippets Groups Projects
  • Eric Blake's avatar
    bfe04d0a
    nbd: Use enum for various negotiation modes · bfe04d0a
    Eric Blake authored
    
    Deciphering the hard-coded list of integer return values from
    nbd_start_negotiate() will only get more confusing when adding support
    for 64-bit extended headers.  Better is to name things in an enum.
    Although the function in question is private to client.c, putting the
    enum in a public header and including an enum-to-string conversion
    will allow its use in more places in upcoming patches.
    
    The enum is intentionally laid out so that operators like <= can be
    used to group multiple modes with similar characteristics, and where
    the least powerful mode has value 0, even though this patch does not
    exploit that.  No semantic change intended.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-ID: <20230608135653.2918540-9-eblake@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    bfe04d0a
    History
    nbd: Use enum for various negotiation modes
    Eric Blake authored
    
    Deciphering the hard-coded list of integer return values from
    nbd_start_negotiate() will only get more confusing when adding support
    for 64-bit extended headers.  Better is to name things in an enum.
    Although the function in question is private to client.c, putting the
    enum in a public header and including an enum-to-string conversion
    will allow its use in more places in upcoming patches.
    
    The enum is intentionally laid out so that operators like <= can be
    used to group multiple modes with similar characteristics, and where
    the least powerful mode has value 0, even though this patch does not
    exploit that.  No semantic change intended.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-ID: <20230608135653.2918540-9-eblake@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>