Skip to content

Commit

Permalink
libjsc/jstatctl: [cleanup] drop is_ATTR macros
Browse files Browse the repository at this point in the history
Private macros to strcmp a key to a jsc attribute
are probably not adding much to readability.
In an effort to make the code more readable, drop these.
  • Loading branch information
garlick committed Mar 28, 2018
1 parent 6519db9 commit 9428a88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 44 deletions.
55 changes: 12 additions & 43 deletions src/common/libjsc/jstatctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,36 +240,6 @@ static const char * jscctx_jobid_path (jscctx_t *ctx, int64_t id)
return (path);
}

static inline bool is_jobid (const char *k)
{
return (!strncmp (JSC_JOBID, k, JSC_MAX_ATTR_LEN))? true : false;
}

static inline bool is_state_pair (const char *k)
{
return (!strncmp (JSC_STATE_PAIR, k, JSC_MAX_ATTR_LEN))? true : false;
}

static inline bool is_rdesc (const char *k)
{
return (!strncmp (JSC_RDESC, k, JSC_MAX_ATTR_LEN))? true : false;
}

static inline bool is_rdl (const char *k)
{
return (!strncmp (JSC_RDL, k, JSC_MAX_ATTR_LEN))? true : false;
}

static inline bool is_rdl_alloc (const char *k)
{
return (!strncmp (JSC_RDL_ALLOC, k, JSC_MAX_ATTR_LEN))? true : false;
}

static inline bool is_pdesc (const char *k)
{
return (!strncmp (JSC_PDESC, k, JSC_MAX_ATTR_LEN))? true : false;
}

static int fetch_and_update_state (zhash_t *aj , int64_t j, int64_t ns)
{
int *t = NULL;
Expand All @@ -291,7 +261,6 @@ static int fetch_and_update_state (zhash_t *aj , int64_t j, int64_t ns)
return (intptr_t) t;
}


/******************************************************************************
* *
* Internal JCB Accessors *
Expand Down Expand Up @@ -1222,22 +1191,22 @@ int jsc_query_jcb (flux_t *h, int64_t jobid, const char *key, char **jcb_str)
if (!key) return -1;
if (jobid_exist (h, jobid) != 0) return -1;

if (is_jobid (key)) {
if (!strcmp (key, JSC_JOBID)) {
if ( (rc = query_jobid (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_jobid failed");
} else if (is_state_pair (key)) {
} else if (!strcmp (key, JSC_STATE_PAIR)) {
if ( (rc = query_state_pair (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_pdesc failed");
} else if (is_rdesc (key)) {
} else if (!strcmp (key, JSC_RDESC)) {
if ( (rc = query_rdesc (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_rdesc failed");
} else if (is_rdl (key)) {
} else if (!strcmp (key, JSC_RDL)) {
if ( (rc = query_rdl (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_rdl failed");
} else if (is_rdl_alloc (key)) {
} else if (!strcmp (key, JSC_RDL_ALLOC)) {
if ( (rc = query_rdl_alloc (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_rdl_alloc failed");
} else if (is_pdesc (key)) {
} else if (!strcmp(key, JSC_PDESC)) {
if ( (rc = query_pdesc (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_pdesc failed");
} else
Expand All @@ -1264,22 +1233,22 @@ int jsc_update_jcb (flux_t *h, int64_t jobid, const char *key,
if (jobid_exist (h, jobid) != 0)
goto done;

if (is_jobid (key)) {
if (!strcmp(key, JSC_JOBID)) {
flux_log (h, LOG_ERR, "jobid attr cannot be updated");
} else if (is_state_pair (key)) {
} else if (!strcmp (key, JSC_STATE_PAIR)) {
if (Jget_obj (jcb, JSC_STATE_PAIR, &o))
rc = update_state (h, jobid, o);
} else if (is_rdesc (key)) {
} else if (!strcmp (key, JSC_RDESC)) {
if (Jget_obj (jcb, JSC_RDESC, &o))
rc = update_rdesc (h, jobid, o);
} else if (is_rdl (key)) {
} else if (!strcmp (key, JSC_RDL)) {
const char *s = NULL;
if (Jget_str (jcb, JSC_RDL, &s))
rc = update_rdl (h, jobid, s);
} else if (is_rdl_alloc (key)) {
} else if (!strcmp (key, JSC_RDL_ALLOC)) {
if (Jget_obj (jcb, JSC_RDL_ALLOC, &o))
rc = update_rdl_alloc (h, jobid, o);
} else if (is_pdesc (key)) {
} else if (!strcmp (key, JSC_PDESC)) {
if (Jget_obj (jcb, JSC_PDESC, &o))
rc = update_pdesc (h, jobid, o);
}
Expand Down
1 change: 0 additions & 1 deletion src/common/libjsc/jstatctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ typedef int (*jsc_handler_f)(const char *base_jcb, void *arg, int errnum);
/* TODO: find a better way to manage this hierarchical
* JCB attributes space
*/
#define JSC_MAX_ATTR_LEN 32
#define JSC_JOBID "jobid"
#define JSC_STATE_PAIR "state-pair"
# define JSC_STATE_PAIR_OSTATE "ostate"
Expand Down

0 comments on commit 9428a88

Please sign in to comment.