#include #define TID_INVALID ((tid_t) - 1) #define CHID_INVALID ((unsigned int)-1) struct remote { tid_t tid; unsigned int chid; }; static struct remote remotes[] = { [SYS_REMOTE_NONE] = {.tid = TID_INVALID, .chid = CHID_INVALID}, [SYS_REMOTE_NSD] = {.tid = TID_INVALID, .chid = CHID_INVALID}, }; static const size_t nr_remotes = sizeof remotes / sizeof remotes[0]; bool sys_remote_get( enum sys_remote_id id, tid_t *out_tid, unsigned int *out_chid) { if (id < 0 || id >= nr_remotes) { return false; } const struct remote *remote = &remotes[id]; if (remote->tid == TID_INVALID || remote->chid == CHID_INVALID) { return false; } *out_tid = remote->tid; *out_chid = remote->chid; return true; } void sys_remote_set(enum sys_remote_id id, tid_t tid, unsigned int chid) { if (id < 0 || id >= nr_remotes) { return; } struct remote *remote = &remotes[id]; remote->tid = tid; remote->chid = chid; }