ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] Style question passing boolean parameters

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Wed, 20 Jun 2012 07:12:26 +0200
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?

 Ciao
    Jörg
-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.