<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Sep 23, 2014 at 10:05 AM, Richard Mudgett <span dir="ltr"><<a href="mailto:rmudgett@digium.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=rmudgett@digium.com&cc=&bcc=&su=&body=','_blank','location=yes,menubar=yes,resizable=yes,width=800,height=600');return false;">rmudgett@digium.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 23, 2014 at 10:51 AM, George Joseph <span dir="ltr"><<a href="mailto:george.joseph@fairview5.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=george.joseph@fairview5.com&cc=&bcc=&su=&body=','_blank','location=yes,menubar=yes,resizable=yes,width=800,height=600');return false;">george.joseph@fairview5.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>On Tue, Sep 23, 2014 at 9:45 AM, George Joseph <span dir="ltr"><<a href="mailto:george.joseph@fairview5.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=george.joseph@fairview5.com&cc=&bcc=&su=&body=','_blank','location=yes,menubar=yes,resizable=yes,width=800,height=600');return false;">george.joseph@fairview5.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I've been working on some changes for config.c and in the process I've found 5 instances of someone attempting to do "cat->name == category_name" instead of "strcmp(cat->name, category_name)". Example:<div><br></div><div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>/* try exact match first, then case-insensitive match */</font></div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>for (cat = config->root; cat; cat = cat->next) {</font></div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>if (cat->name == category_name && (ignored || !cat->ignored))</font></div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>return cat;</font></div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>}</font></div><div><font face="courier new, monospace" size="1"><br></font></div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>for (cat = config->root; cat; cat = cat->next) {</font></div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))</font></div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>return cat;</font></div><div><font face="courier new, monospace" size="1"><span style="white-space:pre-wrap"> </span>}</font></div></div><div><font face="courier new, monospace" size="1"><br></font></div><div><font face="arial, helvetica, sans-serif">The result is that the case sensitive match never succeeds and it's always the case insensitive match that's run.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">My question is... Should I fix these so the case sensitive match works and runs first or just remove the first loop so the match is always case-insensitive? I'm hoping the latter not only because it makes the code simpler but because that's how it's worked for years and suddenly making the match case sensitive might cause unexpected problems.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Thoughts?</font></div><div><br></div></div></blockquote></div></div><div>Forgot to mention...There are other places in the code where the comparison is always case-insensitive.</div></div></div></div></blockquote><div><br></div><div>I was under the impression that the code was done this way<br>initially to avoid doing a string comparison. Though, I'm not<br>sure avoiding the string comparison really buys much in the<br>way of performance anyway.<br><br></div><div>Another reason is if you have several sections named [foo]<br></div><div>and you need to resume with the same [foo] section as last<br>time.<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Richard<br></div></font></span></div><br></div></div>
</blockquote></div>This works only in ast_category_browse where the pointer you're passing in is almost always a pointer you received from the last call to ast_category_browse. It's almost never going to work in ast_category_get because you're probably passing in a constant or a pointer to some other memory location housing the name.</div></div>