Change in libosmocore[master]: osmo_strlcpy: Clarify lenght calculation

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
Mon Sep 21 15:13:55 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/20231 )


Change subject: osmo_strlcpy: Clarify lenght calculation
......................................................................

osmo_strlcpy: Clarify lenght calculation

Change-Id: I78dc7b87d5b42595c0b1392fce61606eae8f6ec8
---
M src/utils.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/20231/1

diff --git a/src/utils.c b/src/utils.c
index 168f85f..772b671 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -576,7 +576,7 @@
 	size_t ret = src ? strlen(src) : 0;
 
 	if (siz) {
-		size_t len = (ret >= siz) ? siz - 1 : ret;
+		size_t len = OSMO_MIN(siz - 1, ret);
 		if (len)
 			memcpy(dst, src, len);
 		dst[len] = '\0';

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I78dc7b87d5b42595c0b1392fce61606eae8f6ec8
Gerrit-Change-Number: 20231
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200921/8ca65462/attachment.htm>


More information about the gerrit-log mailing list