From fe130f7d141a7908fc1bbba62413aae90589f98d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Mon, 6 Aug 2012 14:46:15 +0000 Subject: [PATCH] - Avoid using sizeof()/sizeof() to determine array length - Harmonize literal names with corresponding enum values --- org.glite.lb.common/interface/query_rec.h | 1 + org.glite.lb.common/src/query_rec.c | 3 ++- org.glite.lb.server/src/lb_xml_parse.c.T | 36 +++++++++++++++---------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/org.glite.lb.common/interface/query_rec.h b/org.glite.lb.common/interface/query_rec.h index 9c1623b..4bb1144 100644 --- a/org.glite.lb.common/interface/query_rec.h +++ b/org.glite.lb.common/interface/query_rec.h @@ -99,6 +99,7 @@ typedef enum _edg_wll_QueryOp{ EDG_WLL_QUERY_OP_UNEQUAL, /**< attribute is not equal to the operand value \see _edg_wll_QueryRec */ EDG_WLL_QUERY_OP_CHANGED, /**< attribute has changed from last check; supported only in notification matching \see _edg_wll_QueryRec */ + EDG_WLL_QUERY_OP__LAST } edg_wll_QueryOp; diff --git a/org.glite.lb.common/src/query_rec.c b/org.glite.lb.common/src/query_rec.c index e7de9bb..6dd6d35 100644 --- a/org.glite.lb.common/src/query_rec.c +++ b/org.glite.lb.common/src/query_rec.c @@ -28,8 +28,9 @@ limitations under the License. /** * Names for the predefined types of query attributes + * NOTE: FOR HISTORIC REASONS, The NAME INDEX IS ONE LESS than the corresponding enum value! */ -char *edg_wll_QueryAttrNames[] = { "jobid","owner","status","location","destination", +char *edg_wll_QueryAttrNames[] = { "undef", "jobid","owner","status","location","destination", "donecode","usertag","time","level","host","source", "instance","type","chkpt_tag", "resubmitted", "parent_job", "exitcode", "jdl", "stateentertime", "lastupdatetime", diff --git a/org.glite.lb.server/src/lb_xml_parse.c.T b/org.glite.lb.server/src/lb_xml_parse.c.T index f6b3c04..d775b9c 100644 --- a/org.glite.lb.server/src/lb_xml_parse.c.T +++ b/org.glite.lb.server/src/lb_xml_parse.c.T @@ -101,9 +101,9 @@ static void startJobQueryRec(void *data, const char *el, const char **attr) } break; case 2: - for (i=0; ijob_conditions) break; @@ -115,30 +115,30 @@ static void startJobQueryRec(void *data, const char *el, const char **attr) XMLCtx->bound = 0; } break; - case 3: for (i=0; ijob_conditions) break; if (!XMLCtx->job_conditions[XMLCtx->row]) break; - if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) { + if ( (i) == EDG_WLL_QUERY_ATTR_USERTAG) { if (!attr[0] || !attr[1]) { unexp() break;} if (strcmp(attr[0],"name")) { unexp() break;} XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.tag = strdup(attr[1]); } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME ) { + else if ( (i) == EDG_WLL_QUERY_ATTR_TIME ) { if (!attr[0] || !attr[1]) { unexp() break;} if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); } - if ( (i+1) == EDG_WLL_QUERY_ATTR_JDL_ATTR) { + if ( (i) == EDG_WLL_QUERY_ATTR_JDL_ATTR) { if (!attr[0] || !attr[1]) XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.tag = NULL; else if (strcmp(attr[0],"name")) { unexp() break;} else XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.tag = strdup(attr[1]); } - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr = i+1; + XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr = i; } break; default: unexp(); break; @@ -224,9 +224,9 @@ static void startQueryEventsRequest(void *data, const char *el, const char **att else unexp() break; case 3: - for (i=0; itype == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { if (!XMLCtx->job_conditions) break; @@ -248,37 +248,37 @@ static void startQueryEventsRequest(void *data, const char *el, const char **att } break; - case 4: for (i=0; itype == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { if (!XMLCtx->job_conditions[XMLCtx->row]) break; - if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) { + if ( (i) == EDG_WLL_QUERY_ATTR_USERTAG) { if (!attr[0] || !attr[1]) { unexp() break;} if (attr[0] && strcmp(attr[0],"name")) { unexp() break;} XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.tag = strdup(attr[1]); } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME ) { + else if ( (i) == EDG_WLL_QUERY_ATTR_TIME ) { if (!attr[0] || !attr[1]) { unexp() break;} if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); //printf("\nchecking time attr\n%s = %s (%d)\n\n", attr[0], attr[1], edg_wll_StringToStat(attr[1])); } - XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr = i+1; + XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr = i; } else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_EVENT_CONDITION) { if (!XMLCtx->event_conditions[XMLCtx->row2]) break; - if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) { + if ( (i) == EDG_WLL_QUERY_ATTR_USERTAG) { if (!attr[0] || !attr[1]) { unexp() break;} if (attr[0] && strcmp(attr[0],"name")) { unexp() break;} XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position].attr_id.tag = strdup(attr[1]); } - else if ( (i+1) == EDG_WLL_QUERY_ATTR_TIME ) { + else if ( (i) == EDG_WLL_QUERY_ATTR_TIME ) { if (!attr[0] || !attr[1]) { unexp() break;} if (attr[0] && strcmp(attr[0],"state")) { unexp() break;} XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]); } - XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].attr = i+1; + XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].attr = i; } break; default: unexp(); break; -- 1.8.2.3