GNOME Bugzilla – Bug 704075
Logically Dead code in valid.c
Last modified: 2013-09-30 03:03:35 UTC
In file https://git.gnome.org/browse/libxml2/tree/valid.c At two places the there are conditions which are checked twice. Hence, checking the same condition again, is logically dead code. 1. In function xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) line no 2735-2748 int xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) { ----- Some Code ------- if (doc == NULL) return(-1); if (attr == NULL) return(-1); table = (xmlIDTablePtr) doc->ids; if (table == NULL) return(-1); if (attr == NULL) return(-1); ---- Some Code ----- } Here after first check to (attr==NULL), value of attr will never be NULL(0). So checking the same condition again is logically dead code. 2. Similar thing is happening in function xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) line no 3053-3067 int xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) { ------Some Code ------- if (doc == NULL) return(-1); if (attr == NULL) return(-1); table = (xmlRefTablePtr) doc->refs; if (table == NULL) return(-1); if (attr == NULL) return(-1); -----Some Code ------ } The solution to this is not to check the same condition twice. Remove the re-occurence of same condition in both functions.
Created attachment 250922 [details] [review] Drop checks for already checked
Indeed, that and reformatting cleanup very welcome ! Applied and pushed: https://git.gnome.org/browse/libxml2/commit/?id=0146179120d4f1162f0400a0131bea2e5d600155 thanks for the report and the patch ! Daniel