Wireshark: style tweaks akin to Wireshark practices#262
Merged
vlvkobal merged 2 commits intoFoxIO-LLC:mainfrom Nov 5, 2025
Merged
Wireshark: style tweaks akin to Wireshark practices#262vlvkobal merged 2 commits intoFoxIO-LLC:mainfrom
vlvkobal merged 2 commits intoFoxIO-LLC:mainfrom
Conversation
Member
|
Hi David, the tests fail. Please look at |
Some minor tweaks to the coding style of the Wireshark dissector to bring it closer to the standard practices used in the Wireshark project itself. All changes are compatible with Wireshark 4.6 and should be with 4.4 as well. Define `WS_LOG_DOMAIN`. Allows for more targeted showing/hiding of [log messages](https://www.wireshark.org/docs/wsdg_html/#ChSrcLogging). Use `ws_warning()` instead of `g_warning()` to leverage. Correct spelling of `MAX_SSL_VERSION()` macro. Run script through Wireshark's `tools/convert-glib-types.py` to replace GLib-specific types with C99 standard types (ref Wireshark [#19116](https://gitlab.com/wireshark/wireshark/-/issues/19116)). Run script through Wireshark's `tools/convert-proto-init.py` to remove initialization of static variables, particularly for `hf_*` fields. Unlike variables within functions, static variables are implicitly initialized to 0 by the compiler if not otherwise initialized, so this removes some overhead of static initialization. Make every global variable and every function (except the register and handoff functions) static, since none of them are used outside of this plugin. Remove constant `HFIDS` and instead define `interesting_hfids[]` as having an indefinite number of elements. Use the `array_length()` macro instead for determining the size of the array. It's still calculated at compile time, and removes a potential source of bugs if elements are added to or removed from `interesting_hfids[]` in future changes. Add `g_strfreev()` calls to correspond with each call to `g_strsplit()`, which specifies in its [documentation](https://docs.gtk.org/glib/func.strsplit.html) that its return value must be freed.
Contributor
Author
|
Ah, I see. The tests use Wireshark 4.2.2 which predates the change around initializing static variables. I missed this because I've been doing my in-tree dev work against Wireshark's That part should be easy enough to revert while keeping the rest of the changes, but I'll test it against 4.2.2 to see if there are any other modernisms that would break that version. (I'm assuming you wouldn't test that version if you were able to migrate to something newer.) |
Some minor tweaks to the coding style of the Wireshark dissector to bring it closer to the standard practices used in the Wireshark project itself. All changes are compatible with Wireshark 4.6 and should be with 4.4 as well. Define `WS_LOG_DOMAIN`. Allows for more targeted showing/hiding of [log messages](https://www.wireshark.org/docs/wsdg_html/#ChSrcLogging). Use `ws_warning()` instead of `g_warning()` to leverage. Correct spelling of `MAX_SSL_VERSION()` macro. Run script through Wireshark's `tools/convert-glib-types.py` to replace GLib-specific types with C99 standard types (ref Wireshark [#19116](https://gitlab.com/wireshark/wireshark/-/issues/19116)). Make every global variable and every function (except the register and handoff functions) static, since none of them are used outside of this plugin. Remove constant `HFIDS` and instead define `interesting_hfids[]` as having an indefinite number of elements. Use the `array_length()` macro instead for determining the size of the array. It's still calculated at compile time, and removes a potential source of bugs if elements are added to or removed from `interesting_hfids[]` in future changes. Add `g_strfreev()` calls to correspond with each call to `g_strsplit()`, which specifies in its [documentation](https://docs.gtk.org/glib/func.strsplit.html) that its return value must be freed.
ecdcce4 to
71ee668
Compare
vlvkobal
approved these changes
Nov 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some minor tweaks to the coding style of the Wireshark dissector to bring it closer to the standard practices used in the Wireshark project itself. All changes are compatible with Wireshark 4.6 and should be with 4.4 as well.
Define
WS_LOG_DOMAIN. Allows for more targeted showing/hiding of log messages. Usews_warning()instead ofg_warning()to leverage.Correct spelling of
MAX_SSL_VERSION()macro.Run script through Wireshark's
tools/convert-glib-types.pyto replace GLib-specific types with C99 standard types (ref Wireshark #19116).Make every global variable and every function (except the register and handoff functions) static, since none of them are used outside of this plugin.
Remove constant
HFIDSand instead defineinteresting_hfids[]as having an indefinite number of elements. Use thearray_length()macro instead for determining the size of the array. It's still calculated at compile time, and removes a potential source of bugs if elements are added to or removed frominteresting_hfids[]in future changes.Add
g_strfreev()calls to correspond with each call tog_strsplit(), which specifies in itsdocumentation that its return value must be freed.