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

Sets SEQMAP_TIMEOUT_IN_NSSEQMAP_TIMEOUT_IN_NS as INT64_C #336

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

gsnw
Copy link
Contributor

@gsnw gsnw commented Jul 15, 2024

Fix macOS build warning

seqmap.c:86:13: warning: format specifies type 'long long' but the argument has type 'long' [-Wformat]
            SEQMAP_TIMEOUT_IN_NS, host_nr, ping_count, seqmap_next_id);
            ^~~~~~~~~~~~~~~~~~~~
seqmap.c:60:30: note: expanded from macro 'SEQMAP_TIMEOUT_IN_NS'
#define SEQMAP_TIMEOUT_IN_NS 10000000000
                             ^~~~~~~~~~~
1 warning generated.

@coveralls
Copy link

coveralls commented Jul 15, 2024

Coverage Status

coverage: 85.469%. remained the same
when pulling 0c38fe5 on gsnw:macos-format-typ-SEQMAP_TIMEOUT_IN_NS
into 00d6417 on schweikert:develop.

@auerswal
Copy link
Collaborator

Thanks for noticing this and looking into it, @gsnw!

How about using the INT64_C(…) macro to specify the type of the constant instead of using a cast to int64_t?

On the affected macOS system, the type suffix for the numeric constant would need to be LL to avoid the warning, but on an x86_64 GNU/Linux system the type suffix should be L. The INT64_C(…) macro is intended to choose the correct suffix for the given system.

The following patch works on my x86_64 GNU/Linux system:

diff --git a/src/seqmap.c b/src/seqmap.c
index 62506d0..7675bc1 100644
--- a/src/seqmap.c
+++ b/src/seqmap.c
@@ -57,7 +57,7 @@
 static SEQMAP_VALUE* seqmap_map = NULL;
 static unsigned int seqmap_next_id = 0;
 
-#define SEQMAP_TIMEOUT_IN_NS 10000000000
+#define SEQMAP_TIMEOUT_IN_NS INT64_C(10000000000)
 #define SEQMAP_UNASSIGNED_HOST_NR UINT_MAX
 
 void seqmap_init()

@gsnw gsnw force-pushed the macos-format-typ-SEQMAP_TIMEOUT_IN_NS branch from d65b8bc to 0c38fe5 Compare July 20, 2024 19:07
@gsnw
Copy link
Contributor Author

gsnw commented Jul 20, 2024

Ah thanks, I've learned something again.
I didn't know that yet. I've changed it and tested it.

@gsnw gsnw changed the title Sets SEQMAP_TIMEOUT_IN_NSSEQMAP_TIMEOUT_IN_NS as int64_t Sets SEQMAP_TIMEOUT_IN_NSSEQMAP_TIMEOUT_IN_NS as INT64_C Jul 20, 2024
@gsnw gsnw merged commit b4da5e4 into schweikert:develop Jul 20, 2024
9 checks passed
@gsnw gsnw deleted the macos-format-typ-SEQMAP_TIMEOUT_IN_NS branch July 20, 2024 22:25
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.

4 participants