MCPcopy Create free account
hub / github.com/apache/cloudberry / parse_int_param

Function parse_int_param

src/interfaces/libpq/fe-connect.c:1868–1908  ·  view source on GitHub ↗

* Parse and try to interpret "value" as an integer value, and if successful, * store it in *result, complaining if there is any trailing garbage or an * overflow. This allows any number of leading and trailing whitespaces. */

Source from the content-addressed store, hash-verified

1866 * overflow. This allows any number of leading and trailing whitespaces.
1867 */
1868static bool
1869parse_int_param(const char *value, int *result, PGconn *conn,
1870 const char *context)
1871{
1872 char *end;
1873 long numval;
1874
1875 Assert(value != NULL);
1876
1877 *result = 0;
1878
1879 /* strtol(3) skips leading whitespaces */
1880 errno = 0;
1881 numval = strtol(value, &end, 10);
1882
1883 /*
1884 * If no progress was done during the parsing or an error happened, fail.
1885 * This tests properly for overflows of the result.
1886 */
1887 if (value == end || errno != 0 || numval != (int) numval)
1888 goto error;
1889
1890 /*
1891 * Skip any trailing whitespace; if anything but whitespace remains before
1892 * the terminating character, fail
1893 */
1894 while (*end != '\0' && isspace((unsigned char) *end))
1895 end++;
1896
1897 if (*end != '\0')
1898 goto error;
1899
1900 *result = numval;
1901 return true;
1902
1903error:
1904 appendPQExpBuffer(&conn->errorMessage,
1905 libpq_gettext("invalid integer value \"%s\" for connection option \"%s\"\n"),
1906 value, context);
1907 return false;
1908}
1909
1910#ifndef WIN32
1911/*

Callers 7

setKeepalivesIdleFunction · 0.85
setKeepalivesIntervalFunction · 0.85
setKeepalivesCountFunction · 0.85
setKeepalivesWin32Function · 0.85
setTCPUserTimeoutFunction · 0.85
connectDBCompleteFunction · 0.85
PQconnectPollFunction · 0.85

Calls 2

appendPQExpBufferFunction · 0.85
libpq_gettextFunction · 0.85

Tested by

no test coverage detected