osmo-bts[master]: Handle ctrl cmd allocation failures

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Mar 13 12:44:09 UTC 2017


Patch Set 1:

This is about coding style more than anything else.

The point is that it is not immediately obvious from that local code that you are using a member of ctrl_cmd to decide whether to send further below. Calling ctrl_cmd_create() implies that you want to create a command, and if we were to change its behavior we wouldn't necessarily notice it -- because at least I would assume every caller to overwrite the .value member.

I agree that it is unlikely, but it's a way of telling the reader what exactly is going on without having to think too much, and as a bonus anyone refactoring the code (however unlikely) is immediately told about having forgotten something.

An even nicer way would be to store the 'value' string in a local var, and only allocate the ctrl_cmd in case we really want to send it. That would skip all the assumptions and unnecessary allocations.

On another note, why are we even allocating it; ownership is not passed on to ctrl_cmd_send, so ctrl cmds in general could be local instances without need for allocation.

-- 
To view, visit https://gerrit.osmocom.org/1991
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id19e1ce5fae6f936c9ed93f9a6317b57d28d7311
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-HasComments: No



More information about the gerrit-log mailing list