<div dir="ltr"><div>Hi,</div><div><br></div><div>today I realized a possible problem on the ngx_atoi and ngx_atof functions (may be on all ngx_ato* functions).</div><div><br></div><div>There is no way to distinguish between an error and a valid "-1" string.</div><div><br></div><div>For instance,</div><div><br></div><div>ngx_str_t some_string = ngx_string("-1");</div><div>ngx_int_t x = ngx_atoi(some_string.data, some_string.len);</div><div><br></div><div>if (x == NGX_ERROR) {<br></div><div>  ngx_log_debug(NGX_LOG_DEBUG, ngx_cycle->log, 0, "ERROR");</div><div>} else {</div><div>  ngx_log_debug(NGX_LOG_DEBUG, ngx_cycle->log, 0, "SUCCESS %d", x);</div><div>}</div><div><br></div><div>this code will produce an "ERROR" as output instead of "SUCCESS -1".</div><div>The same result as if the some_string had a value like "xyz".</div><div><br></div><div>I know that this is unlikely to happen that you have a string with "-1", but it is possible.</div><div><br></div><div>What do you think about change these function signature, or add a new one, to receive the output as a parameter something like</div><div><br></div><div><div>ngx_int_t</div><div>ngx_atoi(u_char *line, size_t n, ngx_int_t *result)</div></div><div><br></div><div>using the "result" parameter to store the parsed value and return NGX_OK or NGX_ERROR.</div><div><br></div><div>Kind regards,</div><div>Wandenberg </div><div><br></div></div>