checking errcode in the sql_snprint_error function of rlm_sql_oracle.c
Hello, First, I want to say that I don't know well OCI programming. I'm trying to make interface between FreeRADIUS and Oracle. I found this code in the rlm_sql_oracle module. This part seems a bit strange. If there are errors, errcode variable is larger than 0. but, the function returns -1. I think if errcode is large than 0, function should return 0 not -1. Can you tell me what is correct? static int sql_snprint_error(char *out, size_t outlen, rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config) { sb4 errcode = 0; rlm_sql_oracle_conn_t *conn = handle->conn; rad_assert(conn); out[0] = ''; OCIErrorGet((dvoid *) conn->error, 1, (OraText *) NULL, &errcode, (OraText *) out, outlen, OCI_HTYPE_ERROR); if (!errcode) return -1; return 0; }
On 26 Nov 2015, at 20:08, Kyuyoung Kim <jadebrill@gmail.com> wrote:
Hello, First, I want to say that I don't know well OCI programming. I'm trying to make interface between FreeRADIUS and Oracle. I found this code in the rlm_sql_oracle module. This part seems a bit strange. If there are errors, errcode variable is larger than 0. but, the function returns -1. I think if errcode is large than 0, function should return 0 not -1.
Why? Look at how the function is called. If it's called an error has occurred. If an error has occurred but oracle knows nothing about it, is that an error? Yes. What do the callers of this function do on an error? Print unknown error mostly. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
participants (2)
-
Arran Cudbard-Bell -
Kyuyoung Kim