Change in osmo-pcu[master]: pcu_l1_if: use proper format specifier for PCUIF version

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Aug 20 12:45:16 UTC 2020


pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/19726 )

Change subject: pcu_l1_if: use proper format specifier for PCUIF version
......................................................................


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/c/osmo-pcu/+/19726/1/src/pcu_l1_if.cpp 
File src/pcu_l1_if.cpp:

https://gerrit.osmocom.org/c/osmo-pcu/+/19726/1/src/pcu_l1_if.cpp@499 
PS1, Line 499: 		fprintf(stderr, "PCU interface version number of BTS (%u) is "
> Again, '%u' works fine for 'uint32_t', and we use it in many places (e.g. […]
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).
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.

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.
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.



-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/19726
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ibd15a678a7a8fc840422e2280b0d358138a67e0c
Gerrit-Change-Number: 19726
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-Comment-Date: Thu, 20 Aug 2020 12:45:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria <vyanitskiy at sysmocom.de>
Comment-In-Reply-To: pespin <pespin at sysmocom.de>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200820/b56ad807/attachment.htm>


More information about the gerrit-log mailing list