Commit 42dbbfe2 authored by Josh Kunz's avatar Josh Kunz

Moves error codes into `error.h` header

parent 3a8bc5ba
......@@ -7,8 +7,8 @@ LDADD = ../lib/libcapnet-lib.la ${MUL_LIBS} $(GLIB_LIBS) $(PROTOC_LIBS) \
-lpthread -lssl $(LIBCAP_LIBS)
noinst_HEADERS = \
$(top_srcdir)/include/capnet_log.h crc.h controller.h metadata.h dispatch.h \
obj_decl.h obj.h
obj_decl.h obj.h errors.h
capnet_controller_SOURCES = crc.c \
metadata.c metadata_openstack.c metadata_file.c \
metadata.c metadata_openstack.c metadata_file.c errors.c \
obj_callback.c obj.c dispatch.c controller.c mul_app_main.c
capnet_controller_CFLAGS = -DMUL_APP_V2_MLAPI -DMUL_APP_VTY
......@@ -9,6 +9,7 @@
#include "obj.h"
#include "dispatch.h"
#include "errors.h"
#include "crc.h"
......
......@@ -10,6 +10,7 @@
#include "dispatch.h"
#include "obj.h"
#include "errors.h"
#include "mul_common.h"
......
......@@ -105,10 +105,6 @@ int cn_dispatch_result_notify_bytes(uint64_t for_uuid,
* the cache is used. */
void cn_dispatch_result_cache_init(cn_dispatch_result_cache_t * cache);
/* Returned when the given bytes are parsed as a CPReply packet for an earlier
* message */
#define EWASREPLY -10
/* Dispatch the message stored in the 'bytes' parameter of size 'len' for
* the given principal. The result is stored in 'result' whose byte
* representation can be obtained using cn_dispatch_result_bytes.
......
#include "errors.h"
#include "util.h"
static const char * ERROR_DESCs[] = {
// EEMPTY
"Couldn't perform operation because the datastructure was empty",
// EBADCPTR
"The CPTR provided was either NULL or could not be dereferenced",
// EWASREPLY
"The dispatched message was of the type CPReply, so no result was returned",
};
static inline int error_index(int err) {
return (-err) - __ERROR_BASE;
}
static inline void error_check(int err) {
if (-err < __ERROR_BASE || -err > __ERROR_MAX) {
cn_abort("Tried to get description of unknown error: %d", err);
}
}
const char * cn_error_desc(int err) {
error_check(err);
return ERROR_DESCs[error_index(err)];
}
#ifndef __ERRORS_H__
#define __ERRORS_H__
#define __ERROR_BASE 10
#define EEMPTY -10
#define EBADCPTR -11
#define EWASREPLY -12
/* Update this when you add a new error */
#define __ERROR_MAX 12
const char * cn_error_desc(int err);
#endif
......@@ -7,6 +7,7 @@
#include "metadata.h"
#include "obj.h"
#include "util.h"
#include "errors.h"
#include "capnet_ref.h"
#include "capnet_log.h"
......@@ -1343,7 +1344,8 @@ int cn_rp_recv(struct cnode *rp, cptr_t *recv_cap, cn_objtype_t *type) {
struct cn_rp_elem * e;
if (cn_rp_pop_noput(_rp, &e) != 0) {
cncerr("couldn't pop off of RP\n");
return -1; }
return EEMPTY;
}
// XXX: No wrapping is done on injected objects.
if (cn_rp_elem_is_injected(e)) {
......
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