[Asterisk-code-review] func odbc: NODATA if SQLNumResultCols returned 0 columns on ... (asterisk[13])

Sean Bright asteriskteam at digium.com
Thu May 31 16:40:40 CDT 2018


Sean Bright has posted comments on this change. ( https://gerrit.asterisk.org/9070 )

Change subject: func_odbc: NODATA if SQLNumResultCols returned 0 columns on readsql
......................................................................


Patch Set 1: Code-Review-1

(2 comments)

https://gerrit.asterisk.org/#/c/9070/1/funcs/func_odbc.c
File funcs/func_odbc.c:

https://gerrit.asterisk.org/#/c/9070/1/funcs/func_odbc.c@862
PS1, Line 862: 	if (colcount <= 0) {
             : 		ast_verb(4, "Returned %d columns [%s]\n", colcount, ast_str_buffer(sql));
             : 		buf[0] = '\0';
             : 		ast_copy_string(rowcount, "0", sizeof(rowcount));
             : 		status = "NODATA";
             : 		SQLCloseCursor(stmt);
             : 		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
             : 		release_obj_or_dsn (&obj, &dsn);
             : 		if (!bogus_chan) {
             : 			pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
             : 			pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
             : 			ast_autoservice_stop(chan);
             : 		}
             : 		odbc_datastore_free(resultset);
             : 		return 0;
             : 	}
'rowcount' and 'status' are local variables and we won't use them here unless '!bogus_chan'

Rather than setting them, just use string literals in the calls to pbx_builtin_setvar_helper(), like:

  pbx_builtin_setvar_helper(chan, "ODBCROWS", "0");
  pbx_builtin_setvar_helper(chan, "ODBCSTATUS", "NODATA");


https://gerrit.asterisk.org/#/c/9070/1/funcs/func_odbc.c@1547
PS1, Line 1547: 				break;
Are you sure we shouldn't be returning here instead of breaking?



-- 
To view, visit https://gerrit.asterisk.org/9070
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie0f7bdac6c405aa5bbd38932c7b831f90729ee19
Gerrit-Change-Number: 9070
Gerrit-PatchSet: 1
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-Comment-Date: Thu, 31 May 2018 21:40:40 +0000
Gerrit-HasComments: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180531/c4aa21ef/attachment.html>


More information about the asterisk-code-review mailing list