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@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
Release-acked-by: Paul Durrant <paul@xen.org>
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,
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,
} 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);
}