I've been exploring a few options for the val_to_str function and wmem. One of the tangential things I've been trying to achieve is to make it into a macro so that the compiler will catch format-string mismatches (which have been a source of bugs in the past). This is easy to do inefficiently:
#define val_to_str(VAL, VS, POOL, FMT) (try_val_to_str(VAL, VS) ? try_val_to_str(VAL, VS) : wmem_strdup_printf(POOL, FMT, VAL)) but I've been unable to find a nice way to avoid the second call to try_val_to_str(). I can wrap it in a block and use a temporary variable, but then it can't return a value and no longer behaves like the original function. I can use a single temp global, but that's just ugly and won't work if we ever do multithreading. Can anybody else think of a nice way to do this, or is it just one of those things that's impossible in C? Evan P.S. Languages like python will do what I want with expressions of the form (a() || b()), but not C. ___________________________________________________________________________ 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-requ...@wireshark.org?subject=unsubscribe