fellow_disk_obj: Tighten assertions on alloc.ptr cast

parent 41434fc7
...@@ -597,7 +597,7 @@ struct fellow_disk_obj { ...@@ -597,7 +597,7 @@ struct fellow_disk_obj {
// shaved off one pointer... // shaved off one pointer...
#define FCO_FCS(fco) (&(fco)->fdo_fcs) #define FCO_FCS(fco) (&(fco)->fdo_fcs)
#define FCO_FDO(fco) (void*)(fco)->fdo_fcs.alloc.ptr #define FCO_FDO(fco) fellow_disk_obj(FCO_FCS(fco))
#define FCO_REFCNT(fco) (fco)->fdo_fcs.refcnt #define FCO_REFCNT(fco) (fco)->fdo_fcs.refcnt
#define FCO_STATE(fco) (fco)->fdo_fcs.state #define FCO_STATE(fco) (fco)->fdo_fcs.state
...@@ -1021,11 +1021,12 @@ fellow_busy_io_submit(struct fellow_busy_io *fbio) ...@@ -1021,11 +1021,12 @@ fellow_busy_io_submit(struct fellow_busy_io *fbio)
return (FC_ERRSTR("disk object wrong " x)); \ return (FC_ERRSTR("disk object wrong " x)); \
} while(0) } while(0)
static struct fellow_disk_obj * static inline struct fellow_disk_obj *
fellow_disk_obj(const struct fellow_cache_seg *fcs) fellow_disk_obj(const struct fellow_cache_seg *fcs)
{ {
AN(fcs); AN(fcs);
AN(fcs->alloc.ptr); AN(fcs->alloc.ptr);
assert(FCOS_HIGH(fcs->state) == FCO_HIGH);
return (fcs->alloc.ptr); return (fcs->alloc.ptr);
} }
...@@ -2188,7 +2189,7 @@ fellow_busy_obj_alloc(struct fellow_cache *fc, ...@@ -2188,7 +2189,7 @@ fellow_busy_obj_alloc(struct fellow_cache *fc,
fbo->segdskdowry = dskdowry; fbo->segdskdowry = dskdowry;
// disk object in memory // disk object in memory
fdo = fcs->alloc.ptr; fdo = fellow_disk_obj(fcs);
memset(fdo, 0, fcs->alloc.size); memset(fdo, 0, fcs->alloc.size);
fdo->magic = FELLOW_DISK_OBJ_MAGIC; fdo->magic = FELLOW_DISK_OBJ_MAGIC;
fdo->version = 1; fdo->version = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment