On Jun 19, 2012, at 10:12 PM, 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?
It's one.
Another would be to pass a single flags argument, e.g.
if (cf_save_packets(&cfile, file_name8->str, filetype,
NOT_COMPRESSED|DONT_DISCARD_COMMENTS|DONT_REOPEN) != CF_OK) {
(with some of the flag values #defined to be 0, so that, regardless of the
value of the flag, the value is indicated in the call).
Fewer arguments means, in a call, either fewer pushes onto the stack or fewer
registers required for passing parameters. I'm not sure whether it's
significantly more expensive (or more expensive at all) to test a single bit in
a flags word than to test a Boolean variable on various architectures.
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <[email protected]>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:[email protected]?subject=unsubscribe