-
-
Notifications
You must be signed in to change notification settings - Fork 264
Various fixes for CodeChecker warnings #8938
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
base: master
Are you sure you want to change the base?
Changes from all commits
66bfb4f
3ec8851
4608d5b
49b01df
fd6857c
a6988a4
4e97b5c
7ec3f4b
a6db65e
0fe3203
533aab5
bf4e792
96f1dc0
64ef6a7
e6dd217
0e585d9
2bebfda
c1ed5c5
80189d0
85d238a
dae2d52
9744edb
95d4f4e
f151bfe
d507bd2
362b2c1
b4bced0
50d02ae
59c6b11
389068b
70dc2e3
94c1f5f
b727260
7444677
0667b62
64963c8
ee32271
fa01cd9
81edec9
b14decb
7025b08
e18f681
46b1515
242501c
daf766b
5c87edb
c719015
ee8047e
56ef78d
4a77e6e
a0ddf89
722d47d
ec9541b
3cc0fb2
1f3be44
0284e5a
7abf372
8f70f84
687c238
e7fc91b
d0d88ab
7b65a8e
c6185ab
4a7916a
2cc6b6f
108d0fa
8f23b0a
1519ed2
91d3a10
2d89042
3d40fb5
1e7eedc
930f693
e175d7b
e556c38
9a73c13
a7412ff
d104619
163d580
c3f70f8
c265239
4e21aab
f61cff8
9464971
5a10754
b122e4d
a13dca2
c284505
6aca13d
3e66832
88d1557
09efd7f
f43dd1a
bfa093b
f335f7c
0989f39
e89decc
e8a6aee
fe60534
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,7 @@ StatusVector::ImplStatusVector::ImplStatusVector(const ISC_STATUS* s) noexcept | |
| { | ||
| fb_assert(s); | ||
|
|
||
| clear(); | ||
| ImplStatusVector::clear(); | ||
|
|
||
| // special case - empty initialized status vector, no warnings | ||
| if (s[0] != isc_arg_gds || s[1] != 0 || s[2] != 0) | ||
|
|
@@ -78,7 +78,7 @@ StatusVector::ImplStatusVector::ImplStatusVector(const IStatus* s) noexcept | |
| { | ||
| fb_assert(s); | ||
|
|
||
| clear(); | ||
| ImplStatusVector::clear(); | ||
|
|
||
| if (s->getState() & IStatus::STATE_ERRORS) | ||
| append(s->getErrors()); | ||
|
|
@@ -91,9 +91,9 @@ StatusVector::ImplStatusVector::ImplStatusVector(const Exception& ex) noexcept | |
| m_status_vector(*getDefaultMemoryPool()), | ||
| m_strings(*getDefaultMemoryPool()) | ||
| { | ||
| clear(); | ||
| ImplStatusVector::clear(); | ||
|
|
||
| assign(ex); | ||
| ImplStatusVector::assign(ex); | ||
| } | ||
|
|
||
| StatusVector::StatusVector(ISC_STATUS k, ISC_STATUS c) : | ||
|
|
@@ -143,7 +143,7 @@ void StatusVector::ImplStatusVector::assign(const StatusVector& v) noexcept | |
|
|
||
| void StatusVector::ImplStatusVector::assign(const Exception& ex) noexcept | ||
| { | ||
| clear(); | ||
| ImplStatusVector::clear(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using of class name inside of the class' methods is completely pointless. |
||
| ex.stuffException(m_status_vector); | ||
| putStrArg(0); | ||
| } | ||
|
|
@@ -263,7 +263,7 @@ bool StatusVector::ImplStatusVector::append(const ISC_STATUS* const from, const | |
| if (!count) | ||
| return true; // not sure it's the best option here | ||
|
|
||
| unsigned lenBefore = length(); | ||
| unsigned lenBefore = ImplStatusVector::length(); | ||
| ISC_STATUS* s = m_status_vector.getBuffer(lenBefore + count + 1); | ||
| unsigned int copied = | ||
| fb_utils::copyStatus(&s[lenBefore], count + 1, from, count); | ||
|
|
@@ -273,7 +273,7 @@ bool StatusVector::ImplStatusVector::append(const ISC_STATUS* const from, const | |
|
|
||
| if (!m_warning) | ||
| { | ||
| for (unsigned n = 0; n < length(); ) | ||
| for (unsigned n = 0; n < ImplStatusVector::length(); ) | ||
| { | ||
| if (m_status_vector[n] == isc_arg_warning) | ||
| { | ||
|
|
@@ -407,19 +407,25 @@ Num::Num(ISC_STATUS s) noexcept : | |
| Int64::Int64(SINT64 val) noexcept : | ||
| Str(text) | ||
| { | ||
| snprintf(text, sizeof(text), "%" SQUADFORMAT, val); | ||
| [[maybe_unused]] auto result = snprintf(text, sizeof(text), "%" SQUADFORMAT, val); | ||
| fb_assert(result >= 0); | ||
| } | ||
|
|
||
| Int64::Int64(FB_UINT64 val) noexcept : | ||
| Str(text) | ||
| { | ||
| snprintf(text, sizeof(text), "%" UQUADFORMAT, val); | ||
| [[maybe_unused]] auto result = snprintf(text, sizeof(text), "%" UQUADFORMAT, val); | ||
| fb_assert(result >= 0); | ||
| } | ||
|
|
||
| Quad::Quad(const ISC_QUAD* quad) noexcept : | ||
| Str(text) | ||
| { | ||
| snprintf(text, sizeof(text), "%x:%x", quad->gds_quad_high, quad->gds_quad_low); | ||
| [[maybe_unused]] auto result = snprintf(text, sizeof(text), "%x:%x", | ||
| static_cast<unsigned int>(quad->gds_quad_high), | ||
| quad->gds_quad_low | ||
| ); | ||
| fb_assert(result >= 0); | ||
| } | ||
|
|
||
| Interpreted::Interpreted(const char* text) noexcept : | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -341,51 +341,36 @@ int NoThrowTimeStamp::convertGregorianDateToWeekDate(const struct tm& times) noe | |
| { | ||
| // Algorithm for Converting Gregorian Dates to ISO 8601 Week Date by Rick McCarty, 1999 | ||
| // http://personal.ecu.edu/mccartyr/ISOwdALG.txt | ||
|
|
||
| const int y = times.tm_year + 1900; | ||
| const int dayOfYearNumber = times.tm_yday + 1; | ||
| const int dayOfYear = times.tm_yday + 1; | ||
|
|
||
| // Find the jan1Weekday for y (Monday=1, Sunday=7) | ||
| const int yy = (y - 1) % 100; | ||
| const int c = (y - 1) - yy; | ||
| const int g = yy + yy / 4; | ||
| const int jan1Weekday = 1 + (((((c / 100) % 4) * 5) + g) % 7); | ||
| const int y_1 = y - 1; | ||
| const int yy = y_1 % 100; | ||
| const int c = y_1 - yy; | ||
| const int g = yy + (yy >> 2); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modern compilers are clever enough to reuse pieces of calculation and replace division by 4 with shifts, but division is better readable by human. |
||
| const int jan1Weekday = 1 + (((((c / 100) & 3) * 5) + g) % 7); | ||
|
|
||
| // Find the weekday for y m d | ||
| const int h = dayOfYearNumber + (jan1Weekday - 1); | ||
| const int weekday = 1 + ((h - 1) % 7); | ||
| const int weekday = 1 + ((dayOfYear + jan1Weekday - 2) % 7); | ||
|
|
||
| // Find if y m d falls in yearNumber y-1, weekNumber 52 or 53 | ||
| int yearNumber, weekNumber; | ||
|
|
||
| if ((dayOfYearNumber <= (8 - jan1Weekday)) && (jan1Weekday > 4)) | ||
| if ((dayOfYear <= (8 - jan1Weekday)) & (jan1Weekday > 4)) | ||
| { | ||
| yearNumber = y - 1; | ||
| weekNumber = ((jan1Weekday == 5) || ((jan1Weekday == 6) && | ||
| isLeapYear(yearNumber))) ? 53 : 52; | ||
| const int prevYearLeap = (!(y_1 & 3) && ((y_1 % 100) || !(y_1 % 400))); | ||
| const int is53 = (jan1Weekday == 5) | ((jan1Weekday == 6) & prevYearLeap); | ||
| return 52 + is53; | ||
| } | ||
| else | ||
| { | ||
| yearNumber = y; | ||
|
|
||
| // Find if y m d falls in yearNumber y+1, weekNumber 1 | ||
| const int i = isLeapYear(y) ? 366 : 365; | ||
|
|
||
| if ((i - dayOfYearNumber) < (4 - weekday)) | ||
| { | ||
| yearNumber = y + 1; | ||
| weekNumber = 1; | ||
| } | ||
| // Find if y m d falls in yearNumber y+1, weekNumber 1 | ||
| const int daysInYear = 365 + (!(y & 3) && ((y % 100) || !(y % 400))); | ||
| if ((daysInYear - dayOfYear) < (4 - weekday)) | ||
| { | ||
| return 1; | ||
| } | ||
|
|
||
| // Find if y m d falls in yearNumber y, weekNumber 1 through 53 | ||
| if (yearNumber == y) | ||
| { | ||
| const int j = dayOfYearNumber + (7 - weekday) + (jan1Weekday - 1); | ||
| weekNumber = j / 7; | ||
| if (jan1Weekday > 4) | ||
| weekNumber--; | ||
| } | ||
| const int j = dayOfYear + (7 - weekday) + (jan1Weekday - 1); | ||
| const int weekNumber = (j / 7) - (jan1Weekday > 4); // Subtract 1 if jan1Weekday > 4 | ||
|
|
||
| return weekNumber; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1473,7 +1473,7 @@ SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject | |
| #endif | ||
| #endif | ||
|
|
||
| memset(sh_mem_mutex->mtx_mutex, 0, sizeof(*(sh_mem_mutex->mtx_mutex))); | ||
| memset(sh_mem_mutex->mtx_mutex, 0, sizeof(sh_mem_mutex->mtx_mutex)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is definitely wrong. |
||
| //int state = LOG_PTHREAD_ERROR(pthread_mutex_init(sh_mem_mutex->mtx_mutex, &mattr)); | ||
| state = pthread_mutex_init(sh_mem_mutex->mtx_mutex, &mattr); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -523,7 +523,7 @@ BlockNode* BlockNode::pass2(thread_db* tdbb, CompilerScratch* csb) | |
| const StmtNode* BlockNode::execute(thread_db* tdbb, Request* request, ExeState* exeState) const | ||
| { | ||
| jrd_tra* transaction = request->req_transaction; | ||
| SavNumber savNumber; | ||
| SavNumber savNumber = 0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to move this declaration to the points of real use to make sure that savepoint zero is never used by any mistake. |
||
|
|
||
| switch (request->req_operation) | ||
| { | ||
|
|
@@ -2494,7 +2494,7 @@ void EraseNode::pass1Erase(thread_db* tdbb, CompilerScratch* csb, EraseNode* nod | |
|
|
||
| jrd_rel* parent = NULL; | ||
| jrd_rel* view = NULL; | ||
| StreamType parentStream; | ||
| StreamType parentStream = 0; | ||
|
|
||
| for (;;) | ||
| { | ||
|
|
@@ -5173,7 +5173,6 @@ void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) | |
| { | ||
| inputStart = dsqlScratch->variables.getCount(); | ||
| dsqlScratch->genParameters(parameters, returns); | ||
| returnsPos = dsqlScratch->variables.getCount() - dsqlScratch->outputVariables.getCount(); | ||
| } | ||
|
|
||
| if (parameters.hasData()) | ||
|
|
@@ -5188,6 +5187,8 @@ void ExecBlockNode::genBlr(DsqlCompilerScratch* dsqlScratch) | |
| { | ||
| // This validation is needed only for subroutines. Standard EXECUTE BLOCK moves input | ||
| // parameters to variables and are then validated. | ||
| // Number of input parameters to validate (total variables minus output variables) | ||
| const unsigned returnsPos = dsqlScratch->variables.getCount() - dsqlScratch->outputVariables.getCount(); | ||
|
|
||
| for (unsigned i = inputStart; i < returnsPos; ++i) | ||
| { | ||
|
|
@@ -8035,7 +8036,7 @@ void ModifyNode::pass1Modify(thread_db* tdbb, CompilerScratch* csb, ModifyNode* | |
|
|
||
| jrd_rel* parent = NULL; | ||
| jrd_rel* view = NULL; | ||
| StreamType parentStream, parentNewStream; | ||
| StreamType parentStream = 0, parentNewStream = 0; | ||
|
|
||
| // To support nested views, loop until we hit a table or a view with user-defined triggers | ||
| // (which means no update). | ||
|
|
@@ -9090,7 +9091,7 @@ bool StoreNode::pass1Store(thread_db* tdbb, CompilerScratch* csb, StoreNode* nod | |
|
|
||
| jrd_rel* parent = NULL; | ||
| jrd_rel* view = NULL; | ||
| StreamType parentStream; | ||
| StreamType parentStream = 0; | ||
|
|
||
| // To support nested views, loop until we hit a table or a view with user-defined triggers | ||
| // (which means no update). | ||
|
|
@@ -12437,7 +12438,7 @@ static void validateExpressions(thread_db* tdbb, const Array<ValidateInfo>& vali | |
| if (i->boolean->execute(tdbb, request) == TriState(false)) | ||
| { | ||
| // Validation error -- report result | ||
| const char* value; | ||
| const char* value = nullptr; | ||
| VaryStr<TEMP_STR_LENGTH> temp; | ||
|
|
||
| const dsc* desc = EVL_expr(tdbb, request, i->value); | ||
|
|
@@ -12449,6 +12450,7 @@ static void validateExpressions(thread_db* tdbb, const Array<ValidateInfo>& vali | |
| else if (!length) | ||
| value = ""; | ||
| else | ||
| fb_assert(value); | ||
| const_cast<char*>(value)[length] = 0; // safe cast - data is actually on the stack | ||
|
|
||
| string name; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2668,6 +2668,8 @@ static void gen_put_segment( const act* action, int column) | |
| args.pat_ident1 = blob->blb_len_ident; | ||
| args.pat_ident2 = blob->blb_buff_ident; | ||
| args.pat_string1 = global_status_name; | ||
| args.pat_long1 = NULL; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and in other places where variable type is |
||
| args.pat_long2 = NULL; | ||
| PATTERN_expand((USHORT) column, pattern1, &args); | ||
|
|
||
| set_sqlcode(action, column); | ||
|
|
||
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 value is better to be named
trig_invalidand a check for valid type was assigned should be added.