<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18472">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">menuselect: Don't erroneously recompile modules.<br><br>A bug in menuselect can cause modules that are disabled<br>by default to be recompiled every time a recompilation<br>occurs. This occurs for module categories that are NOT<br>positive output, as for these categories, the modules<br>contained in the makeopts file indicate modules which<br>should NOT be selected. The existing procedure of iterating<br>through these modules to mark modules as present is thus<br>insufficient. This has led to modules with a default_enabled<br>tag of "no" to get deleted and recompiled every time, even<br>when they haven't changed.<br><br>To fix this, we now modify the mark as present behavior<br>for module categories that are not positive output. For<br>these, we start by iterating through the module tree<br>and marking all modules as present, then go back and<br>mark anything contained in the makeopts file as not<br>present. This ensures that makeopt selections are actually<br>used properly, regardless of whether a module category<br>uses positive output or not.<br><br>ASTERISK-29728 #close<br><br>Change-Id: Idf2974c4ed8d0ba3738a92f08a6082b234277b95<br>---<br>M menuselect/menuselect.c<br>1 file changed, 59 insertions(+), 11 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/72/18472/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/menuselect/menuselect.c b/menuselect/menuselect.c</span><br><span>index 3153ce0..54283ed 100644</span><br><span>--- a/menuselect/menuselect.c</span><br><span>+++ b/menuselect/menuselect.c</span><br><span>@@ -1130,8 +1130,7 @@</span><br><span> return res;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*! \brief Given the string representation of a member and category, mark it as present in a given input file */</span><br><span style="color: hsl(0, 100%, 40%);">-static void mark_as_present(const char *member, const char *category)</span><br><span style="color: hsl(120, 100%, 40%);">+static void mark_as_present_helper(const char *member, const char *category, int present)</span><br><span> {</span><br><span> struct category *cat;</span><br><span> struct member *mem;</span><br><span>@@ -1142,31 +1141,44 @@</span><br><span> negate = 1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- print_debug("Marking %s of %s as present\n", member, category);</span><br><span style="color: hsl(120, 100%, 40%);">+ print_debug("Marking %s of %s as %s\n", member, category, present ? "present" : "not present");</span><br><span> </span><br><span> AST_LIST_TRAVERSE(&categories, cat, list) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (strcmp(category, cat->name))</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strcmp(category, cat->name)) {</span><br><span> continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> AST_LIST_TRAVERSE(&cat->members, mem, list) {</span><br><span> if (mem->is_separator) {</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span> if (!strcmp(member, mem->name)) {</span><br><span style="color: hsl(0, 100%, 40%);">- mem->was_enabled = mem->enabled = (negate ? !cat->positive_output : cat->positive_output);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (present) {</span><br><span style="color: hsl(120, 100%, 40%);">+ mem->was_enabled = mem->enabled = (negate ? !cat->positive_output : cat->positive_output);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ mem->was_enabled = mem->enabled = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);</span><br><span> break;</span><br><span> }</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (!mem)</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!mem) {</span><br><span> fprintf(stderr, "member '%s' in category '%s' not found, ignoring.\n", member, category);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> break;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!cat)</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!cat) {</span><br><span> fprintf(stderr, "category '%s' not found! Can't mark '%s' as disabled.\n", category, member);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Given the string representation of a member and category, mark it as present in a given input file */</span><br><span style="color: hsl(120, 100%, 40%);">+#define mark_as_present(member, category) mark_as_present_helper(member, category, 1)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Given the string representation of a member and category, mark it as not present in a given input file */</span><br><span style="color: hsl(120, 100%, 40%);">+#define mark_as_not_present(member, category) mark_as_present_helper(member, category, 0)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> unsigned int enable_member(struct member *mem)</span><br><span> {</span><br><span> struct reference *dep;</span><br><span>@@ -1380,6 +1392,9 @@</span><br><span> }</span><br><span> </span><br><span> while (fgets(buf, PARSE_BUF_SIZE, f)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct category *cat;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct member *mem;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> lineno++;</span><br><span> </span><br><span> if (strlen_zero(buf))</span><br><span>@@ -1414,11 +1429,44 @@</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- while ((member = strsep(&parse, " \n"))) {</span><br><span style="color: hsl(0, 100%, 40%);">- member = skip_blanks(member);</span><br><span style="color: hsl(0, 100%, 40%);">- if (strlen_zero(member))</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_LIST_TRAVERSE(&categories, cat, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strcmp(category, cat->name)) {</span><br><span> continue;</span><br><span style="color: hsl(0, 100%, 40%);">- mark_as_present(member, category);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!cat->positive_output) {</span><br><span style="color: hsl(120, 100%, 40%);">+ print_debug("Category %s is NOT positive output\n", cat->name);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* if NOT positive_output, then if listed in makeopts, it's disabled! */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* this means that what's listed in menuselect.makeopts is a list of modules</span><br><span style="color: hsl(120, 100%, 40%);">+ * that are NOT selected, so we can't use that to mark things as present.</span><br><span style="color: hsl(120, 100%, 40%);">+ * In fact, we need to mark everything as present, UNLESS it's listed</span><br><span style="color: hsl(120, 100%, 40%);">+ * in menuselect.makeopts */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_LIST_TRAVERSE(&cat->members, mem, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (mem->is_separator) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ mem->was_enabled = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);</span><br><span style="color: hsl(120, 100%, 40%);">+ } </span><br><span style="color: hsl(120, 100%, 40%);">+ /* okay, now go ahead, and mark anything listed in makeopts as NOT present */</span><br><span style="color: hsl(120, 100%, 40%);">+ while ((member = strsep(&parse, " \n"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ member = skip_blanks(member);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strlen_zero(member)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ mark_as_not_present(member, category);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ print_debug("Category %s is positive output\n", cat->name);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* if present, it was enabled (e.g. MENUSELECT_CFLAGS, MENUSELECT_UTILS, MENUSELECT_MOH, etc. */</span><br><span style="color: hsl(120, 100%, 40%);">+ while ((member = strsep(&parse, " \n"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ member = skip_blanks(member);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strlen_zero(member)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ mark_as_present(member, category);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span> }</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18472">change 18472</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18472"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: Idf2974c4ed8d0ba3738a92f08a6082b234277b95 </div>
<div style="display:none"> Gerrit-Change-Number: 18472 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>