[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] tools: make libxenhypfs interface more future proof
commit dde6174ada5280cd9a6396e3b12606360a0d29a3 Author: Juergen Gross <jgross@xxxxxxxx> AuthorDate: Tue Jun 2 08:00:21 2020 +0200 Commit: Wei Liu <wl@xxxxxxx> CommitDate: Tue Jun 2 12:05:30 2020 +0000 tools: make libxenhypfs interface more future proof As compilers are free to choose the width of an enum they should be avoided in stable interfaces when declaring a variable. So the struct xenhypfs_dirent definition should be modified to have explicitly sized members for type and encoding and the related enums should be defined separately. Additionally it is better to have a larger flags member in that struct with the "writable" indicator occupying only a single bit. This will make future additions easier. Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Signed-off-by: Juergen Gross <jgross@xxxxxxxx> Acked-by: Wei Liu <wl@xxxxxxx> Release-acked-by: Paul Durrant <paul@xxxxxxx> --- tools/libs/hypfs/core.c | 2 +- tools/libs/hypfs/include/xenhypfs.h | 31 ++++++++++++++++++------------- tools/misc/xenhypfs.c | 3 ++- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tools/libs/hypfs/core.c b/tools/libs/hypfs/core.c index d4309b5ae2..c91e165705 100644 --- a/tools/libs/hypfs/core.c +++ b/tools/libs/hypfs/core.c @@ -204,7 +204,7 @@ static void xenhypfs_set_attrs(struct xen_hypfs_direntry *entry, dirent->type = xenhypfs_type_blob; } - dirent->is_writable = entry->max_write_len; + dirent->flags = entry->max_write_len ? XENHYPFS_FLAG_WRITABLE : 0; } void *xenhypfs_read_raw(xenhypfs_handle *fshdl, const char *path, diff --git a/tools/libs/hypfs/include/xenhypfs.h b/tools/libs/hypfs/include/xenhypfs.h index ab157edceb..25432d2a16 100644 --- a/tools/libs/hypfs/include/xenhypfs.h +++ b/tools/libs/hypfs/include/xenhypfs.h @@ -26,22 +26,27 @@ struct xentoollog_logger; typedef struct xenhypfs_handle xenhypfs_handle; +enum xenhypfs_type { + xenhypfs_type_dir, + xenhypfs_type_blob, + xenhypfs_type_string, + xenhypfs_type_uint, + xenhypfs_type_int, + xenhypfs_type_bool, +}; + +enum xenhypfs_encoding { + xenhypfs_enc_plain, + xenhypfs_enc_gzip +}; + struct xenhypfs_dirent { char *name; size_t size; - enum { - xenhypfs_type_dir, - xenhypfs_type_blob, - xenhypfs_type_string, - xenhypfs_type_uint, - xenhypfs_type_int, - xenhypfs_type_bool - } type; - enum { - xenhypfs_enc_plain, - xenhypfs_enc_gzip - } encoding; - bool is_writable; + unsigned short type; + unsigned short encoding; + unsigned int flags; +#define XENHYPFS_FLAG_WRITABLE 0x00000001 }; xenhypfs_handle *xenhypfs_open(struct xentoollog_logger *logger, diff --git a/tools/misc/xenhypfs.c b/tools/misc/xenhypfs.c index 5145b8969f..5da24aed90 100644 --- a/tools/misc/xenhypfs.c +++ b/tools/misc/xenhypfs.c @@ -125,7 +125,8 @@ static int xenhypfs_ls(char *path) } else { for (i = 0; i < n; i++) printf("%s r%c %s\n", xenhypfs_type(ent + i), - ent[i].is_writable ? 'w' : '-', ent[i].name); + (ent[i].flags & XENHYPFS_FLAG_WRITABLE) ? 'w' : '-', + ent[i].name); free(ent); } -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |