Wireshark mailing list archives
Re: Style question passing boolean parameters
From: Bill Meier <wmeier () newsguy com>
Date: Wed, 20 Jun 2012 11:46:00 -0400
On 6/20/2012 1:12 AM, Joerg Mayer wrote:
The following commit retriggered an allergic reaction to controlling function behaviour via booleans: if (cf_save_packets(&cfile, file_name8->str, filetype, FALSE/*compressed */, FALSE/*discard_comments */, FALSE/* dont_reopen */) != CF_OK) { To me, this is sort of unreadable without the comments and ugly looking with the comments. My favourite nightmare in this regard in wireshark source is dissect_ieee80211_common which has 4 boolean parameters and no comments anywhere where it is called. What ways are there to fix this? Is replacing the boolean types by an enum with speaking elements a valid solution? As an example, the above might read: if (cf_save_packets(&cfile, file_name8->str, filetype, NOT_COMPRESSED, DONT_DISCARD_COMMENTS, DONT_REOPEN) != CF_OK) { What would be good names for the elements in the enums?
I have the same "allergic reactiuon" as described above.Using enums would help; Unfortunately they all share a single namespace, so something like CF_SAVE_PACKETS_NOT_COMPRESSED, etc might be required; this seems just a bit clumsy (but doable).
___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: http://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- Style question passing boolean parameters Joerg Mayer (Jun 19)
- Re: Style question passing boolean parameters Stephen Fisher (Jun 20)
- Re: Style question passing boolean parameters Bill Meier (Jun 20)
- Re: Style question passing boolean parameters Guy Harris (Jun 21)
- Re: Style question passing boolean parameters Guy Harris (Jun 22)