GNOME Bugzilla – Bug 705392
Not reachable code in tree.c
Last modified: 2014-10-06 12:21:12 UTC
Created attachment 250757 [details] [review] Removes the never reachable if-else condition In file : https://git.gnome.org/browse/libxml2/tree/tree.c Function : xmlDOMWrapNsMapAddItem At line : 7846 if ((position != -1) && (position != 0)) return(NULL); i.e if value of position can either be 1 or 0. Line: 7882 if (map->first == NULL) { ----Some COde ---- } else if (position == -1) { ---Some COde--- } else if (position == 0) { ----Some Code ---- } else return(NULL); In above if-else statements if map-first is not NULL then: one of the else-if condition will be executed as value of position can either be 1 or 0. So, the final else condition will never be executed. Patch for fix is attached.
*** Bug 705391 has been marked as a duplicate of this bug. ***
sometimes redundant information can make the code clearer/more maintainable and that could be the case here, so I will remove the last else but I will leave the second condition on the if as it reminds people editing the code what the context is and the code would not break in case we accepted more initial cases. Maintainability is more important, the compiler can optimize this anyway, people time is more precious than compiler time ... thanks, Daniel