From: Joseph Morrow Date: Mon, 23 Mar 2015 18:49:12 +0000 (-0400) Subject: Removed a single instance of the usage of a "magic number" in the stack. X-Git-Tag: 1.2.0+RC1~1855^2~75 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b5f25afb60df159c524980b5565107673d6a638f;p=platform%2Fupstream%2Fiotivity.git Removed a single instance of the usage of a "magic number" in the stack. After walking through the logic in ValidateQuery() its clear that there was an intention add a second #define, but this must have been over- looked at that time. There a single #define to avoid usage of a "magic number" (or a raw value, ie. "2") but it was actually being used in the wrong spot in the code. Change-Id: I2ff045005ccacc9822280d93e6b20bfac8df1cbd Signed-off-by: Joseph Morrow Reviewed-on: https://gerrit.iotivity.org/gerrit/539 Reviewed-by: Erich Keane Tested-by: jenkins-iotivity --- diff --git a/resource/csdk/stack/src/occollection.c b/resource/csdk/stack/src/occollection.c index fd18359..7103c81 100644 --- a/resource/csdk/stack/src/occollection.c +++ b/resource/csdk/stack/src/occollection.c @@ -37,7 +37,8 @@ #define TAG PCF("occollection") -#define NUM_PARAM_IN_QUERY 2 +#define NUM_PARAM_IN_QUERY 2 // The expected number of parameters in a query +#define NUM_FIELDS_IN_QUERY 2 // The expected number of fields in a query static OCStackResult CheckRTParamSupport(const OCResource* resource, const char* rtPtr) { @@ -142,14 +143,14 @@ ValidateQuery (const char *query, OCResourceHandle resource, innerToken = strtok_r (NULL, "=", &endToken); } } - if (numParam != 2) + if (numParam != NUM_PARAM_IN_QUERY) { // Query parameter should be of the form if=. String should not have & or = return OC_STACK_INVALID_QUERY; } token = strtok_r (NULL, "&", &endStr); } - if (numFields > NUM_PARAM_IN_QUERY) + if (numFields > NUM_FIELDS_IN_QUERY) { // current release supports one IF value, one RT value and no other params return OC_STACK_INVALID_QUERY;