Migrate to error constants in glacier

This commit is contained in:
Drew Galbraith 2023-06-21 18:28:54 -07:00
parent 3ab9b4d818
commit 0b86a94f14
30 changed files with 171 additions and 114 deletions

View file

@ -1,5 +1,6 @@
#pragma once
#include <glacier/status/error.h>
#include <stdint.h>
#include <zcall.h>
@ -37,13 +38,10 @@ template <typename T>
z_err_t Channel::ReadStructAndCap(T* obj, uint64_t* cap) {
uint64_t num_bytes = sizeof(T);
uint64_t num_caps = 1;
uint64_t ret = ZChannelRecv(chan_cap_, &num_bytes, obj, &num_caps, cap);
RET_ERR(ZChannelRecv(chan_cap_, &num_bytes, obj, &num_caps, cap));
if (ret != Z_OK) {
return ret;
}
if (num_caps != 1 || num_bytes != sizeof(T)) {
return Z_ERR_INVALID;
return glcr::FAILED_PRECONDITION;
}
return Z_OK;
return glcr::OK;
}

View file

@ -10,11 +10,3 @@ void dbgln(const char* fmt, ...);
void check(uint64_t);
void crash(const char*, z_err_t);
#define RET_ERR(expr) \
{ \
z_err_t _tmp_err = expr; \
if (_tmp_err != Z_OK) { \
return _tmp_err; \
} \
}