<p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/19726">View Change</a></p><p>1 comment:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/19726/1/src/pcu_l1_if.cpp">File src/pcu_l1_if.cpp:</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-pcu/+/19726/1/src/pcu_l1_if.cpp@499">Patch Set #1, Line 499:</a> <code style="font-family:monospace,monospace">         fprintf(stderr, "PCU interface version number of BTS (%u) is "</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">Again, '%u' works fine for 'uint32_t', and we use it in many places (e.g. […]</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Because if you use %u instead of PRIu32 AFAIU you are assuming you always run on architectures where word size is 32bit, and that parameters are expanded to word size when stored and passed to functions with variable number of parameters (for uint8_t and uint16_t).<br>So you see, lots of assumptions, which happen to work for probably 99.9% of cpu architectures running nowadays, but which may hit you back at some point.</p><p style="white-space: pre-wrap; word-wrap: break-word;">It's easy, instead of following assumptions, if you want to print a uint32_t, use its standard printf indicator PRIu32 and be done with it, same as if you want to print an unsigned long you would use %lu and not %u. Otherwise, cast the value to (unsigned int) and use %u.<br>If using %u is fine for you then so be it, I'm just pointing out what I think is formally better from maintainment and portability point of view.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/19726">change 19726</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-pcu/+/19726"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ibd15a678a7a8fc840422e2280b0d358138a67e0c </div>
<div style="display:none"> Gerrit-Change-Number: 19726 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Thu, 20 Aug 2020 12:45:16 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Comment-In-Reply-To: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Comment-In-Reply-To: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: comment </div>