After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 705392 - Not reachable code in tree.c
Not reachable code in tree.c
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other Linux
: Normal enhancement
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
: 705391 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-08-03 10:03 UTC by Gaurav
Modified: 2014-10-06 12:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Removes the never reachable if-else condition (463 bytes, patch)
2013-08-03 10:03 UTC, Gaurav
none Details | Review

Description Gaurav 2013-08-03 10:03:34 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.
Comment 1 André Klapper 2013-08-04 12:22:49 UTC
*** Bug 705391 has been marked as a duplicate of this bug. ***
Comment 2 Daniel Veillard 2014-10-06 12:21:12 UTC
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