-
Notifications
You must be signed in to change notification settings - Fork 175
Cleanups from NCBI as of May 2024 #560
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
Conversation
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.
| 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/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 <ucko@ncbi.nlm.nih.gov>
* 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 <ucko@ncbi.nlm.nih.gov>
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 <ucko@ncbi.nlm.nih.gov>
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 <ucko@ncbi.nlm.nih.gov>
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 <ucko@ncbi.nlm.nih.gov>
* 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 <ucko@ncbi.nlm.nih.gov>
d6ce7b0 to
bbe2948
Compare
| @@ -0,0 +1,64 @@ | |||
| #ifndef _tdsguard_afBM6E9n8CuIFSBHNNblq5 | |||
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'll add copyright lines.
| /* Ensure assert is always active. */ | ||
| #undef NDEBUG | ||
| #ifdef assert | ||
| # error "Include test_base.h (or common.h) earlier" |
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 test turns out to be too strong for some tests. The problem is that some tests include, at the beginning, a C file and that's supposed to be the first thing they do (all some linking trick). Would be enough to check that NDEBUG is not defined instead ?
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 already adjusted these tests to start with appropriate #include directives (common.h for tds tests, test_base.h for replacements tests), which AFAICT should be fine. I do see compilation errors for this branch, oops, but due to different formal considerations I'll need to address -- old MSVC versions complain about a C99ism I accidentally put in the tds read_login_info, and newer versions complain about a missed change to collations.c that somehow slipped through the cracks.
At any rate, if this particular construct is a problem, I reckon
#if defined(assert) && defined(NDEBUG)
# error "..."
#endif
#undef NDEBUG
/* ... */would still be one in at least some cases.
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.
That sounds reasonable. Specifically it fails to build due to some duplicate definition. One due to some MingW headers, another due to some potential Windows macros. But mostly, the trick of including the C file to avoid exporting symbols works well if you include the C file as soon as possible.
I'll do the change. Possibly also some new tests came out, I'll add required changes if needed.
|
Updated and merged last bits. |
This PR contains three formally interdependent commits from #555; inasmuch as there's an overall theme, it's formal cleanups.