|Summary:||ASTERISK-03174: [PATCH] refactor and clean up code|
|Reporter:||Kevin P. Fleming (kpfleming)||Labels:|
|Date Opened:||2005-01-03 18:05:31.000-0600||Date Closed:||2005-01-16 19:13:41.000-0600|
|Environment:||Attachments:||( 0) config_refactoring_rev2.diff.txt|
|Description:||Patch derived from bugs ASTERISK-2993020 and ASTERISK-3063099; this part is only the code reorganization, optimization and some minor reformatting.|
****** ADDITIONAL INFORMATION ******
Disclaimer is on file.
|Comments:||By: Clod Patry (junky) 2005-01-04 23:25:44.000-0600|
can i ask what's that exactly?
return !!ast_category_get(config, category_name);
!! ? is the same as:
return ast_category_get(config, category_name);
By: Kevin P. Fleming (kpfleming) 2005-01-05 07:50:42.000-0600
It's a little bit of C magic :-)
ast_category_get returns either NULL, or a pointer. We don't want to return that, we want to return an int (boolean value).
It goes like this:
If ast_category_get returns NULL, the first ! turns it into "true" (1), the second turns it into "false" (0).
If ast_category_get returns a pointer, the first ! turns it into "false" (0), the second turns it into "true" (1).
So in other words, it's a simple way to collapse any value into the normal "boolean" values.
By: Kevin P. Fleming (kpfleming) 2005-01-15 15:24:46.000-0600
I'm not sure what else this needs; it's a pretty straightforward cleanup patch that doesn't change any behavior.
By: Mark Spencer (markster) 2005-01-15 18:17:27.000-0600
config.c:173: warning: no previous prototype for `ast_category_get'
config.c:192: warning: `variable_get' defined but not used
config.c:267: warning: `category_remove' defined but not used
config.c:288: warning: `variable_remove' defined but not used
config.c:309: warning: `variable_clone' defined but not used
This one doesn't cleanly apply (anymore) and even when it did, it created several functions which are entirely unused. That's why it's not in yet :)
By: Kevin P. Fleming (kpfleming) 2005-01-15 20:06:14.000-0600
Rediffed against current CVS, and unused functions removed.
By: Mark Spencer (markster) 2005-01-15 23:58:19.000-0600
Fixed in CVS head.