<p><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202">View Change</a></p><p>12 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c">File src/mslookup/mslookup.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c@128">Patch Set #15, Line 128:</a> <code style="font-family:monospace,monospace">strncmp(a->msisdn, b->msisdn, sizeof(a->msisdn));</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">What if a->msisdn is e.g. '900' while b->msisdn is '900369'? They are not equal, but strncmp() would return 0. I think you either need to compare strlen() too, or just use regular strcmp().</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c@130">Patch Set #15, Line 130:</a> <code style="font-family:monospace,monospace">return 0;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Rather assert() here.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c@211">Patch Set #15, Line 211:</a> <code style="font-family:monospace,monospace">if (result->rc == OSMO_MSLOOKUP_RC_RESULT) </code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Cosmetic: this can be replaced by '} else {'.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c@232">Patch Set #15, Line 232:</a> <code style="font-family:monospace,monospace">64</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Given that IPv6 addresses can be quite long, I would use at least 128...</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c@253">Patch Set #15, Line 253:</a> <code style="font-family:monospace,monospace">10</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">EINVAL</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c@256">Patch Set #15, Line 256:</a> <code style="font-family:monospace,monospace">11</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">ENOMEM</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c@266">Patch Set #15, Line 266:</a> <code style="font-family:monospace,monospace">struct osmo_mslookup_query *q</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Parameters need to be documented. At least I would like to know whether it's a pointer to a caller-allocated structure, or do we allocate it here?</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup.c@274">Patch Set #15, Line 274:</a> <code style="font-family:monospace,monospace">*q = (struct osmo_mslookup_query){};</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">So this is a fancy way to initialize a caller-allocated structure, right?<br>IMHO, memset(q, 0x00, sizeof(*q)) looks way more cleaner...</p><p style="white-space: pre-wrap; word-wrap: break-word;">I would also place this after all checks below (compiler would do this for us). If we return rc != 0, the caller shall consider *q uninitialized.</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup_client.c">File src/mslookup/mslookup_client.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup_client.c@45">Patch Set #15, Line 45:</a> <code style="font-family:monospace,monospace">struct</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">const</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup_client.c@59">Patch Set #15, Line 59:</a> <code style="font-family:monospace,monospace">talloc_zero</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">I would avoid zero-initialization here, because 2/3 fields are explicitly initialized below. Just add 'next_request_handle = 0', so we would avoid a redundant write cycle.</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup_client_fake.c">File src/mslookup/mslookup_client_fake.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup_client_fake.c@59">Patch Set #15, Line 59:</a> <code style="font-family:monospace,monospace">talloc_zero</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Zero-initialization is redundant here (see the next line).</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202/15/src/mslookup/mslookup_client_fake.c@136">Patch Set #15, Line 136:</a> <code style="font-family:monospace,monospace">talloc_zero</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">same</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16202">change 16202</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.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.osmocom.org/c/osmo-hlr/+/16202"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-hlr </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I83487ab8aad1611eb02e997dafbcb8344da13df1 </div>
<div style="display:none"> Gerrit-Change-Number: 16202 </div>
<div style="display:none"> Gerrit-PatchSet: 15 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Thu, 28 Nov 2019 17:01:35 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>