Skip to content
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

ADBDEV-6655: Fix -Wunused-but-set-variable errors #1107

Open
wants to merge 9 commits into
base: adb-7.2.0
Choose a base branch
from

Conversation

dnskvlnk
Copy link
Collaborator

@dnskvlnk dnskvlnk commented Nov 6, 2024

Fix -Wunused-but-set-variable errors

Commit 4be34c4 fixed the most part of 'unused-but-set-variable' errors, but some
of them were suppressed by -Wno-unused-but-set-variable flag in configure
script.

This patch removes this flag and fixes all the errors that emerged after. The
error can't be fixed for files generated by Yacc, so
-Wno-unused-but-set-variable was remained intact for them.

Co-authored-by: Vladimir Sarmin <[email protected]>

@bandetto bandetto changed the title Fix -Wunused-but-set-variable errors ADBDEV-6655: Fix -Wunused-but-set-variable errors Jan 20, 2025
Comment on lines +232 to +240
#ifdef USE_ASSERT_CHECKING
AOCODMLState *state;
#endif
Assert(aocoDMLStates.state_table);

state = (AOCODMLState *) hash_search(aocoDMLStates.state_table,
#ifdef USE_ASSERT_CHECKING
state = (AOCODMLState *)
#endif
hash_search(aocoDMLStates.state_table,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to use one ifdef and don't cast, because the type of state does not matter

	Assert(aocoDMLStates.state_table);
#ifdef USE_ASSERT_CHECKING
	void* state =
#endif
		hash_search(aocoDMLStates.state_table,

/* Remember if it's a system catalog */
is_system_catalog = IsSystemRelation(heapRelation);
#endif

/* Appendoptimized catalog tables are not supported. */
Assert(!is_system_catalog);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about Assert(!IsSystemRelation(heapRelation)); ? IsSystemRelation doesn't change anything

@@ -1858,6 +1868,7 @@ aoco_index_build_range_scan(Relation heapRelation,
* only one of those is requested.
*/
Assert(!(anyvisible && checking_uniqueness));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can replace checking_uniqueness with (indexInfo->ii_Unique || indexInfo->ii_ExclusionOps != NULL). In this case we can remove variable and ifdef

Comment on lines +2168 to +2170
#ifdef USE_ASSERT_CHECKING
err =
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use one ifdef instead of two

Suggested change
#ifdef USE_ASSERT_CHECKING
err =
#endif
#ifdef USE_ASSERT_CHECKING
int err =
#endif

@@ -1611,7 +1613,9 @@ aorow_compression_ratio_internal(Relation parentrel)

/* Do the query. */
ret = SPI_execute(sqlstmt.data, false, 0);
#ifdef USE_ASSERT_CHECKING
proc = (int) SPI_processed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use SPI_processed in Assert and remove the proc variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants