added COW_ERR_POISON

error_handling
Avril 4 years ago
parent 960f18a6e0
commit 30a0176604
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -18,6 +18,8 @@ enum cow_err_kind {
COW_ERR_SIZE, COW_ERR_SIZE,
/// `mmap()` failed. /// `mmap()` failed.
COW_ERR_MAP, COW_ERR_MAP,
/// Trying to use a poisoned cow
COW_ERR_POISONED,
_COW_ERR_SIZE, _COW_ERR_SIZE,
}; };

@ -122,7 +122,9 @@ void cow_free(cow_t* restrict cow)
cow_t* cow_clone(const cow_t* cow) cow_t* cow_clone(const cow_t* cow)
{ {
if(UNLIKELY(cow->poisoned)) { if(UNLIKELY(cow->poisoned)) {
_cow_set_err(COW_ERR_POISONED);
TRACE("WARNING: attempted to clone poisoned object at %p", (const void*)cow); TRACE("WARNING: attempted to clone poisoned object at %p", (const void*)cow);
return NULL; return NULL;
} }
cow_t clone; cow_t clone;

@ -21,6 +21,7 @@ namespace _cow_error {
setmsg(ret, COW_ERR_FDCREATE, "failed to create shmfd (memfd_create())"); setmsg(ret, COW_ERR_FDCREATE, "failed to create shmfd (memfd_create())");
setmsg(ret, COW_ERR_SIZE, "failed to set shmfd size (ftruncate())"); setmsg(ret, COW_ERR_SIZE, "failed to set shmfd size (ftruncate())");
setmsg(ret, COW_ERR_MAP, "failed to map shmfd (mmap())"); setmsg(ret, COW_ERR_MAP, "failed to map shmfd (mmap())");
setmsg(ret, COW_ERR_POISONED, "trying to use a poisoned cow");
return ret; return ret;
} }

Loading…
Cancel
Save