<p>Corey Farrell <strong>posted comments</strong> on this change.</p><p><a href="https://gerrit.asterisk.org/6816">View Change</a></p><p>Patch set 1:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4;">Code-Review -1</span></p><p>(14 comments)</p><ul style="list-style: none; padding-left: 20px;"><li><p><a href="https://gerrit.asterisk.org/#/c/6816/1//COMMIT_MSG">Commit Message:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1//COMMIT_MSG@7">Patch Set #1, Line 7:</a> <code style="font-family:monospace,monospace">This is the actual commit... didn't add the new files in...</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">The commit message needs to say what we're doing.  Maybe:<br>cdr: Add support for beanstalkd backend.</p></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c">File cdr/cdr_beanstalkd.c:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@4">Patch Set #1, Line 4:</a> <code style="font-family:monospace,monospace"> * Copyright (C) 2004 - 2005</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">2017</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@202">Patch Set #1, Line 202:</a> <code style="font-family:monospace,monospace">    char *cat = NULL;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">No need to initialize cat.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@241">Patch Set #1, Line 241:</a> <code style="font-family:monospace,monospace">                if (!strcasecmp(v->name, "enabled"))</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Need brackets for each conditional block.  Also the remaining options should be chained together with 'else if' blocks so we stop comparing v->name once we find a match.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@244">Patch Set #1, Line 244:</a> <code style="font-family:monospace,monospace">                if (!newenablecdr) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This will disable cdr_beanstalkd if 'enabled=true' is not the first option in the config file.  This block should just be removed, you already do the right thing with newenablecdr after you destroy the config.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@282">Patch Set #1, Line 282:</a> <code style="font-family:monospace,monospace">    char strStartTime[80] = "";</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This is unconditionally set below so it doesn't need to be initialized here.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@284">Patch Set #1, Line 284:</a> <code style="font-family:monospace,monospace">    char strEndTime[80] = "";</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This is unconditionally set below so it doesn't need to be initialized here.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@288">Patch Set #1, Line 288:</a> <code style="font-family:monospace,monospace">    if (!enablecdr)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Brackets</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@291">Patch Set #1, Line 291:</a> <code style="font-family:monospace,monospace">    int bs_id, bs_socket = bs_connect(bs_host, bs_port);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">All variable declarations are required to be at the top of the code block.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Also we prefer that each variable get it's own line and statement:<br>int bs_id;<br>int bs_socket;</p><p style="white-space: pre-wrap; word-wrap: break-word;">Do we need to check the result of bs_connect or will bs_use react correctly to bs_socket==-1?</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@325">Patch Set #1, Line 325:</a> <code style="font-family:monospace,monospace">    snprintf(cdr_buffer, BEANSTALK_JOB_SIZE,</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">snprintf won't encode quotes (") for you, so if any field contains a quote it will not be valid JSON. I suspect you will need to use ast_json_pack and ast_json_dump_string.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@339">Patch Set #1, Line 339:</a> <code style="font-family:monospace,monospace">    if (bs_id > 0)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Brackets</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@353">Patch Set #1, Line 353:</a> <code style="font-family:monospace,monospace">    if (customfields)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Brackets.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/cdr/cdr_beanstalkd.c@377">Patch Set #1, Line 377:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">.support_level = AST_MODULE_SUPPORT_CORE,<br>.load = load_module,<br>.unload = unload_module,<br>.reload = reload,<br>.load_pri = AST_MODPRI_CDR_DRIVER,<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Please tab indent these lines.</p></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/6816/1/configs/samples/cdr_beanstalkd.conf.sample">File configs/samples/cdr_beanstalkd.conf.sample:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/6816/1/configs/samples/cdr_beanstalkd.conf.sample">Patch Set #1:</a> </p><p style="white-space: pre-wrap; word-wrap: break-word;">The sample config should comment-out all options.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/6816">change 6816</a>. To unsubscribe, 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/6816"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: I6b7d2964ae5b39a35ec23da460a725e6c0d7c214 </div>
<div style="display:none"> Gerrit-Change-Number: 6816 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nir Simionovich (GreenfieldTech - Israel) <nirs@greenfieldtech.net> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Comment-Date: Mon, 16 Oct 2017 17:06:44 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>