Browse code

Modifying the return value of cfg_set* functions, in order to make a difference between variable not found and error cases.

Miklos Tirpak authored on 05/12/2007 16:30:57
Showing 1 changed files
... ...
@@ -151,7 +151,13 @@ error:
151 151
 	return -1;
152 152
 }
153 153
 
154
-/* sets the value of a variable without the need of commit */
154
+/* sets the value of a variable without the need of commit
155
+ *
156
+ * return value:
157
+ *   0: success
158
+ *  -1: error
159
+ *   1: variable has not been found
160
+ */
155 161
 int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
156 162
 			void *val, unsigned int val_type)
157 163
 {
... ...
@@ -175,7 +181,7 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
175 181
 
176 182
 	/* look-up the group and the variable */
177 183
 	if (cfg_lookup_var(group_name, var_name, &group, &var))
178
-		return -1;
184
+		return 1;
179 185
 
180 186
 	/* check whether we have to convert the type */
181 187
 	if (convert_val(val_type, val, CFG_INPUT_TYPE(var), &v))
... ...
@@ -341,7 +347,13 @@ static int cfg_var_size(cfg_mapping_t *var)
341 347
 	}
342 348
 }
343 349
 
344
-/* sets the value of a variable but does not commit the change */
350
+/* sets the value of a variable but does not commit the change
351
+ *
352
+ * return value:
353
+ *   0: success
354
+ *  -1: error
355
+ *   1: variable has not been found
356
+ */
345 357
 int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, str *var_name,
346 358
 			void *val, unsigned int val_type)
347 359
 {
... ...
@@ -367,7 +379,7 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, str *var_name,
367 379
 
368 380
 	/* look-up the group and the variable */
369 381
 	if (cfg_lookup_var(group_name, var_name, &group, &var))
370
-		return -1;
382
+		return 1;
371 383
 
372 384
 	/* check whether we have to convert the type */
373 385
 	if (convert_val(val_type, val, CFG_INPUT_TYPE(var), &v))