<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/3043/">https://reviewboard.asterisk.org/r/3043/</a>
     </td>
    </tr>
   </table>
   <br />











<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/3043/diff/3/?file=49085#file49085line1367" style="color: black; font-weight: bold; text-decoration: underline;">branches/12/res/res_pjsip/pjsip_configuration.c</a>
    <span style="font-weight: normal;">

     (Diff revision 3)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1236</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">format_string</span> <span class="o">=</span> <span class="n">ast_calloc</span><span class="p">(</span><span class="mi">64</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="kt">char</span><span class="p">));</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1237</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">separator</span> <span class="o">=</span> <span class="n">ast_calloc</span><span class="p">(</span><span class="n">max_name_width</span> <span class="o">+</span> <span class="n">max_value_width</span> <span class="o">+</span> <span class="mi">8</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="kt">char</span><span class="p">));</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1238</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">memset</span><span class="p">(</span><span class="n">separator</span><span class="p">,</span> <span class="sc">'='</span><span class="p">,</span> <span class="n">max_name_width</span> <span class="o">+</span> <span class="n">max_value_width</span> <span class="o">+</span> <span class="mi">3</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1239</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">separator</span><span class="p">[</span><span class="n">max_name_width</span> <span class="o">+</span> <span class="n">max_value_width</span> <span class="o">+</span> <span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1240</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1241</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">snprintf</span><span class="p">(</span><span class="n">format_string</span><span class="p">,</span> <span class="mi">64</span><span class="p">,</span> <span class="s">" %%-%ds : %%s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">max_name_width</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1242</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">ast_cli</span><span class="p">(</span><span class="n">context</span><span class="o">-></span><span class="n">a</span><span class="o">-></span><span class="n">fd</span><span class="p">,</span> <span class="n">format_string</span><span class="p">,</span> <span class="s">"ParameterName"</span><span class="p">,</span> <span class="s">"ParameterValue"</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This produces GCC warnings with my version of GCC (4.6.3).

You need to use a defined format string here for safety purposes. You can't just create your format string during runtime because the compiler verifies it against the arguments provided to ast_cli.

I'm pretty sure there are ways to achieve what you want here just by using a slightly more elaborate format string. Check out this patch I wrote for manager show commands for something similar: https://reviewboard.asterisk.org/r/2143/

Always remember to make sure your changes compile with developer mode enabled. To turn on developer mode, use the --enable-dev-mode option when configuring like so:
$./configure --enable-dev-mode</pre>
</div>
<br />



<p>- Jonathan Rose</p>


<br />
<p>On December 5th, 2013, 6:27 p.m. UTC, George Joseph wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers.</div>
<div>By George Joseph.</div>


<p style="color: grey;"><i>Updated Dec. 5, 2013, 6:27 p.m.</i></p>







<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="https://issues.asterisk.org/jira/browse/ASTERISK-22610">ASTERISK-22610</a>


</div>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Implements the following cli commands:
pjsip list aors
pjsip list auths
pjsip list channels
pjsip list contacts
pjsip list endpoints
pjsip show aor(s)
pjsip show auth(s)
pjsip show channels
pjsip show endpoint(s)

Also...
Minor modifications made to the AMI command implementations to facilitate reuse.
New function ast_variable_list_sort added to config.c and config.h to implement variable list sorting.
New api ast_sip_for_each_identify added to module res_pjsip_endpoint_identifier_ip. Required new files res_pjsip_endpoint_identifier_ip.h and res_pjsip_endpoint_identifier_ip.exports.in.

Implementation of the summary statistics is still pending.
I'm sure there will be lots of feedback here. :)</pre>
  </td>
 </tr>
</table>



<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>branches/12/res/res_pjsip_registrar.c <span style="color: grey">(403390)</span></li>

 <li>branches/12/res/res_pjsip_endpoint_identifier_ip.exports.in <span style="color: grey">(PRE-CREATION)</span></li>

 <li>branches/12/res/res_pjsip_endpoint_identifier_ip.c <span style="color: grey">(403390)</span></li>

 <li>branches/12/res/res_pjsip/pjsip_configuration.c <span style="color: grey">(403390)</span></li>

 <li>branches/12/res/res_pjsip/location.c <span style="color: grey">(403390)</span></li>

 <li>branches/12/res/res_pjsip/include/res_pjsip_private.h <span style="color: grey">(403390)</span></li>

 <li>branches/12/main/config.c <span style="color: grey">(403390)</span></li>

 <li>branches/12/include/asterisk/res_pjsip_endpoint_identifier_ip.h <span style="color: grey">(PRE-CREATION)</span></li>

 <li>branches/12/include/asterisk/res_pjsip.h <span style="color: grey">(403390)</span></li>

 <li>branches/12/include/asterisk/config.h <span style="color: grey">(403390)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/3043/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>