GNOME Bugzilla – Bug 731424
#ifdef spaghetti for load_user_special_dirs() implementations
Last modified: 2015-04-23 05:21:54 UTC
While working on Bug #731313, I noticed that the different platform-specific implementations of load_user_special_dirs are each controlled by a self-contained #if/#endif block that tests one or more platform tokens. This logic makes it hard to add a new implementation because each existing one might need to have its #if logic upgraded to avoid the cases where the new implementation should be used instead. The various #if lines are a bit far apart in the code, and I found it easy to lose track of them and have them be out of sync. It would be clearer if this were one unified #if/#elsif/.../#endif, so that the fallback or precedence is obvious and implementations further down in the .c do not need to know about what earlier ones might exist. Alternately, similar to include-once guards in .h files, each #if/#endif block could #define a token (same token for all). Then each implementation could simply check if that token is undefined (along with what platform features would allow the implementation to be used) rather than for the inverses of all previous implementations' platform features. If either of these ideas sounds reasonable, I'd be happy to make patches.
(In reply to comment #0) > It would be clearer if this were one unified #if/#elsif/.../#endif, so that the > fallback or precedence is obvious and implementations further down in the .c do > not need to know about what earlier ones might exist. sure
Created attachment 278215 [details] [review] Unified #if/#elif/#endif
Review of attachment 278215 [details] [review]: Looks like a reasonable improvement. Thanks.
Could someone push this? I don't have the commit bit.
(In reply to Daniel Macks from comment #4) > Could someone push this? I don't have the commit bit. Nevermind...was already pushed. Stupid local repo out-of-sync:(