-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanups from NCBI as of May 2024 #560
base: master
Are you sure you want to change the base?
Conversation
src/dblib/dbpivot.c
Outdated
*s++ = strdup(string_value(pc)); | ||
*s++ = string_value(pc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice spot
src/tds/challenge.c
Outdated
p = strchr(user_name, '\\'); | ||
p = user_name ? strchr(user_name, '\\') : NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is useless, compiler bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
src/tds/challenge.c
Outdated
if (p != NULL) { | ||
user_name = p + 1; | ||
user_name_len = strlen(user_name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useless too, although in this case compiler can't much help, the username here has to have that kind of format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was concerned that the (indirect) caller might have supplied an unsuitably formatted username, but a closer look reveals that tds7_send_auth
checks for a little-endian UCS-2 backslash before kicking off the call chain that leads to make_ntlm_v2_hash
.
src/tds/config.c
Outdated
login->valid_configuration = 0; | ||
if (login) | ||
login->valid_configuration = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
login
is used dozens of times in this function, we would have crash much sooner than here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous uses are all contingent on specific option values, so a (hypothetical!) call along the lines of
tds_parse_conf_section("unimplemented", value, NULL);
could otherwise crash right there, but I don't know why the analyzer singled that one line out.
src/tds/query.c
Outdated
if (!buf) { | ||
*out_len = 0; | ||
return NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
caller should handle the error due to NULL
and not use out_len
... but won't hurt initializing it
@@ -156,7 +156,7 @@ tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int te | |||
case CALCPARAM: | |||
switch (*text) { | |||
case '!': | |||
if (pnum <= tokcount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice spot
src/tds/challenge.c
Outdated
if (client_data == NULL || client_data_len <= 0) | ||
return NULL; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useless code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Perhaps more _len
variables and arguments should be size_t
or some other unsigned type for clarity, though.
src/odbc/convert_tds2sql.c
Outdated
TDSICONV *conv = curcol->char_conv; | ||
if (curcol == NULL) { | ||
odbc_errs_add(&stmt->errs, "HY013", NULL); | ||
return SQL_NULL_DATA; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curcol
is never NULL
here.
Merged part of "Formally address static analyzer concerns.". About the |
Thanks! As for |
|
Even with my additional adjustment in place, I wouldn't be looking to do anything to There's also the matter of centrally suppressing the dialog boxes Windows usually pops up when anything crashes (conditionally on a |
You can call |
Good idea. I'll want to make this library distinct from |
I suppose by It's not clear from your paragraph the part about offline tests and online tests. One part of the paragraphs says that "those tests (and some others) all work offline" while another that "C++ Toolkit runs the online tests via a wrapper". So apparently one sentence applies to some tests and latter to other ones. |
To clarify:
|
* Conditionally stub out the tests that require threading (as of 1.4.12) and don't yet have such logic. * include/freetds/thread.h: Never try to add extra checks around stubs. Signed-off-by: Aaron M. Ucko <[email protected]>
* Introduce a <freetds/utils/test_base.h> that for now simply ensures that assertions in test-specific code will always be active and pulls in <config.h>. (Tests that use assertions are still responsible for including <assert.h> themselves, but <config.h> is generally best included as early as possible.) * Start every common.h with #include <freetds/utils/test_base.h> and src/tds/unittests/{parsing,tls}.c with #include "common.h". (Every other unit test with an accompanying common.h already had that form.) * Don't directly undefine NDEBUG or include <config.h> anywhere in */src/unittests. Signed-off-by: Aaron M. Ucko <[email protected]>
Define it in the recently introduced <freetds/utils/test_base.h> (which now includes <freetds/macros.h> accordingly) as int main(int argc TDS_UNUSED, char **argv TDS_UNUSED) so that main can have the same signature in tests that ignore any arguments as in tests that consult arguments without yielding any warnings. Use this macro for all tests to pave the way for introducing a central main wrapper around what will then be a test-specific test_main. Signed-off-by: Aaron M. Ucko <[email protected]>
Consult the environment variable DIAG_SILENT_ABORT (if present), looking for a value starting with Y or y. To that end, adjust TEST_MAIN to call test-specific entry points test_main and incorporate a new tds_test_base library defining a wrapper main that, on Windows, first suppresses any possible source of crash dialog boxes. Signed-off-by: Aaron M. Ucko <[email protected]>
Extend the recently introduced tds_test_base library to supply a new COMMON_PWD data structure (mostly based on ctlib tests'), an instance thereof (the only one in practice), functions for working with it, and the default (relative) path to try. Adjust everything else to use this setup rather than a local variant thereof. Let historical variable names such as SERVER continue to work within dblib tests because all online dblib tests need to consult them, but explicitly go through the instance elsewhere, including dblib tests' common.c. Signed-off-by: Aaron M. Ucko <[email protected]>
* Add more explicit sanity checks and initializers. * vstrbuild.c (tds_vstrbuild): Use unsigned int for counts that will never be negative. * rpc_ct_setparam.c (ex_display_results): Avoid memory leaks in some error cases. Signed-off-by: Aaron M. Ucko <[email protected]>
d6ce7b0
to
bbe2948
Compare
This PR contains three formally interdependent commits from #555; inasmuch as there's an overall theme, it's formal cleanups.