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

in_splunk: fix warnings #7706

Merged
merged 2 commits into from
Jul 20, 2023
Merged

Conversation

nokute78
Copy link
Collaborator

This patch is to fix following warnings.

[ 59%] Building C object plugins/in_splunk/CMakeFiles/flb-plugin-in_splunk.dir/splunk_prot.c.o
/home/taka/git/fluent-bit/plugins/in_splunk/splunk_prot.c: In function ‘process_json_payload_pack’:
/home/taka/git/fluent-bit/plugins/in_splunk/splunk_prot.c:317:9: warning: unused variable ‘ret’ [-Wunused-variable]
  317 |     int ret;
      |         ^~~
/home/taka/git/fluent-bit/plugins/in_splunk/splunk_prot.c: In function ‘process_hec_raw_payload’:
/home/taka/git/fluent-bit/plugins/in_splunk/splunk_prot.c:549:9: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
  549 |     int type = -1;
      |         ^~~~
In file included from /home/taka/git/fluent-bit/plugins/in_splunk/splunk_prot.c:20:
/home/taka/git/fluent-bit/plugins/in_splunk/splunk_prot.c: In function ‘splunk_prot_handle’:
/home/taka/git/fluent-bit/include/fluent-bit/flb_input_plugin.h:41:50: warning: too many arguments for format [-Wformat-extra-args]
   41 |             flb_log_print(FLB_LOG_WARN, NULL, 0, "[input:%s:%s] " fmt,  \
      |                                                  ^~~~~~~~~~~~~~~~
/home/taka/git/fluent-bit/plugins/in_splunk/splunk_prot.c:718:13: note: in expansion of macro ‘flb_plg_warn’
  718 |             flb_plg_warn(ctx->ins, "missing credentials in request headers", ret);
      |             ^~~~~~~~~~~~
/home/taka/git/fluent-bit/include/fluent-bit/flb_input_plugin.h:41:50: warning: too many arguments for format [-Wformat-extra-args]
   41 |             flb_log_print(FLB_LOG_WARN, NULL, 0, "[input:%s:%s] " fmt,  \
      |                                                  ^~~~~~~~~~~~~~~~
/home/taka/git/fluent-bit/plugins/in_splunk/splunk_prot.c:721:13: note: in expansion of macro ‘flb_plg_warn’
  721 |             flb_plg_warn(ctx->ins, "wrong credentials in request headers", ret);
      |             ^~~~~~~~~~~~

Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [N/A] Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • [N/A] Backport to latest stable release.

Debug/Valgrind output

$ valgrind --leak-check=full bin/flb-rt-in_splunk 
==26710== Memcheck, a memory error detector
==26710== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==26710== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==26710== Command: bin/flb-rt-in_splunk
==26710== 
Test health...                                  ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test collector...                               ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test collector_event...                         ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test collector_raw...                           ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test collector_raw_multilines...                ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test collector_gzip...                          ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test collector_event_gzip...                    ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test collector_raw_multilines_gzip...           ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test tag_key...                                 ==26710== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
SUCCESS: All unit tests have passed.
==26710== 
==26710== HEAP SUMMARY:
==26710==     in use at exit: 0 bytes in 0 blocks
==26710==   total heap usage: 20,730 allocs, 20,730 frees, 12,062,092 bytes allocated
==26710== 
==26710== All heap blocks were freed -- no leaks are possible
==26710== 
==26710== For lists of detected and suppressed errors, rerun with: -s
==26710== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

nokute78 added 2 commits July 15, 2023 07:23
Signed-off-by: Takahiro Yamashita <[email protected]>
Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78 nokute78 temporarily deployed to pr July 14, 2023 22:36 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 14, 2023 22:36 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 14, 2023 22:36 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 14, 2023 22:56 — with GitHub Actions Inactive
type = HTTP_CONTENT_TEXT;
}
else {
else if (header->val.len != 10 ||
Copy link
Member

Choose a reason for hiding this comment

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

@cosmo0920 please check this changes (the operator changed from && to ||

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine. This is because these lines of representation was created from:

!(header->val.len == 10 && strncasecmp(header->val.data, "text/plain", 10) == 0

Apply the negate operators (== -> != and && -> ||):

header->val.len != 10 || strncasecmp(header->val.data, "text/plain", 10) != 0

type = HTTP_CONTENT_TEXT;
}
else {
else if (header->val.len != 10 ||
Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine. This is because these lines of representation was created from:

!(header->val.len == 10 && strncasecmp(header->val.data, "text/plain", 10) == 0

Apply the negate operators (== -> != and && -> ||):

header->val.len != 10 || strncasecmp(header->val.data, "text/plain", 10) != 0

@edsiper edsiper merged commit 3523271 into fluent:master Jul 20, 2023
@nokute78 nokute78 deleted the in_splunk_fix_warnings branch July 21, 2023 10:50
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