[S] Change in libosmocore[master]: util: add OSMO_STRBUF_REMAIN()

2023-12-07 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email )

 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: util: add OSMO_STRBUF_REMAIN()
..

util: add OSMO_STRBUF_REMAIN()

This code already exists twice, and upcoming patch will need this as
well in logging.c. Add a macro to remove the code dup.

Related: OS#6284
Related: Ib577a5e0d7450ce93ff21f37ba3262704cbf4752
Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
---
M include/osmocom/core/utils.h
1 file changed, 19 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index ee7cfa4..2a3670b 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -249,7 +249,7 @@
 #define OSMO_STRBUF_APPEND(STRBUF, func, args...) do { \
if (!(STRBUF).pos) \
(STRBUF).pos = (STRBUF).buf; \
-   size_t _sb_remain = (STRBUF).buf ? (STRBUF).len - ((STRBUF).pos 
- (STRBUF).buf) : 0; \
+   size_t _sb_remain = OSMO_STRBUF_REMAIN(STRBUF); \
int _sb_l = func((STRBUF).pos, _sb_remain, ##args); \
if (_sb_l < 0 || (size_t)_sb_l > _sb_remain) \
(STRBUF).pos = (STRBUF).buf + (STRBUF).len; \
@@ -281,6 +281,9 @@
 #define OSMO_STRBUF_PRINTF(STRBUF, fmt, args...) \
OSMO_STRBUF_APPEND(STRBUF, snprintf, fmt, ##args)

+/*! Return remaining space for characters and terminating nul in the given 
struct osmo_strbuf. */
+#define OSMO_STRBUF_REMAIN(STRBUF) ((STRBUF).buf ? (STRBUF).len - 
((STRBUF).pos - (STRBUF).buf) : 0)
+
 /*! Like OSMO_STRBUF_APPEND(), but for function signatures that return the 
char* buffer instead of a length.
  * When using this function, the final STRBUF.chars_needed may not reflect the 
actual number of characters needed, since
  * that number cannot be obtained from this kind of function signature.
@@ -292,7 +295,7 @@
 #define OSMO_STRBUF_APPEND_NOLEN(STRBUF, func, args...) do { \
if (!(STRBUF).pos) \
(STRBUF).pos = (STRBUF).buf; \
-   size_t _sb_remain = (STRBUF).buf ? (STRBUF).len - ((STRBUF).pos 
- (STRBUF).buf) : 0; \
+   size_t _sb_remain = OSMO_STRBUF_REMAIN(STRBUF); \
if (_sb_remain) { \
func((STRBUF).pos, _sb_remain, ##args); \
} \

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
Gerrit-Change-Number: 35206
Gerrit-PatchSet: 3
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: osmith 
Gerrit-MessageType: merged


[S] Change in libosmocore[master]: util: add OSMO_STRBUF_REMAIN()

2023-12-06 Thread neels
Attention is currently required from: neels.

Hello Jenkins Builder, laforge, osmith,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email

to look at the new patch set (#3).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder

The change is no longer submittable: Verified is unsatisfied now.


Change subject: util: add OSMO_STRBUF_REMAIN()
..

util: add OSMO_STRBUF_REMAIN()

This code already exists twice, and upcoming patch will need this as
well in logging.c. Add a macro to remove the code dup.

Related: OS#6284
Related: Ib577a5e0d7450ce93ff21f37ba3262704cbf4752
Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
---
M include/osmocom/core/utils.h
1 file changed, 19 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/06/35206/3
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
Gerrit-Change-Number: 35206
Gerrit-PatchSet: 3
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: osmith 
Gerrit-Attention: neels 
Gerrit-MessageType: newpatchset


[S] Change in libosmocore[master]: util: add OSMO_STRBUF_REMAIN()

2023-12-05 Thread neels
Attention is currently required from: neels.

Hello Jenkins Builder, laforge, osmith,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder

The change is no longer submittable: Verified is unsatisfied now.


Change subject: util: add OSMO_STRBUF_REMAIN()
..

util: add OSMO_STRBUF_REMAIN()

This code already exists twice, and upcoming patch will need this as
well in logging.c. Add a macro to remove the code dup.

Related: OS#6284
Related: Ib577a5e0d7450ce93ff21f37ba3262704cbf4752
Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
---
M include/osmocom/core/utils.h
1 file changed, 19 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/06/35206/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
Gerrit-Change-Number: 35206
Gerrit-PatchSet: 2
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: osmith 
Gerrit-Attention: neels 
Gerrit-MessageType: newpatchset


[S] Change in libosmocore[master]: util: add OSMO_STRBUF_REMAIN()

2023-12-04 Thread laforge
Attention is currently required from: neels.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email )

Change subject: util: add OSMO_STRBUF_REMAIN()
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
Gerrit-Change-Number: 35206
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: osmith 
Gerrit-Attention: neels 
Gerrit-Comment-Date: Mon, 04 Dec 2023 08:37:54 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in libosmocore[master]: util: add OSMO_STRBUF_REMAIN()

2023-12-04 Thread osmith
Attention is currently required from: neels.

osmith has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email )

Change subject: util: add OSMO_STRBUF_REMAIN()
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
Gerrit-Change-Number: 35206
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith 
Gerrit-Attention: neels 
Gerrit-Comment-Date: Mon, 04 Dec 2023 08:11:51 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in libosmocore[master]: util: add OSMO_STRBUF_REMAIN()

2023-12-03 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email )


Change subject: util: add OSMO_STRBUF_REMAIN()
..

util: add OSMO_STRBUF_REMAIN()

This code already exists twice, and upcoming patch will need this as
well in logging.c. Add a macro to remove the code dup.

Related: OS#6284
Related: Ib577a5e0d7450ce93ff21f37ba3262704cbf4752
Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
---
M include/osmocom/core/utils.h
1 file changed, 19 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/06/35206/1

diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index ee7cfa4..2a3670b 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -249,7 +249,7 @@
 #define OSMO_STRBUF_APPEND(STRBUF, func, args...) do { \
if (!(STRBUF).pos) \
(STRBUF).pos = (STRBUF).buf; \
-   size_t _sb_remain = (STRBUF).buf ? (STRBUF).len - ((STRBUF).pos 
- (STRBUF).buf) : 0; \
+   size_t _sb_remain = OSMO_STRBUF_REMAIN(STRBUF); \
int _sb_l = func((STRBUF).pos, _sb_remain, ##args); \
if (_sb_l < 0 || (size_t)_sb_l > _sb_remain) \
(STRBUF).pos = (STRBUF).buf + (STRBUF).len; \
@@ -281,6 +281,9 @@
 #define OSMO_STRBUF_PRINTF(STRBUF, fmt, args...) \
OSMO_STRBUF_APPEND(STRBUF, snprintf, fmt, ##args)

+/*! Return remaining space for characters and terminating nul in the given 
struct osmo_strbuf. */
+#define OSMO_STRBUF_REMAIN(STRBUF) ((STRBUF).buf ? (STRBUF).len - 
((STRBUF).pos - (STRBUF).buf) : 0)
+
 /*! Like OSMO_STRBUF_APPEND(), but for function signatures that return the 
char* buffer instead of a length.
  * When using this function, the final STRBUF.chars_needed may not reflect the 
actual number of characters needed, since
  * that number cannot be obtained from this kind of function signature.
@@ -292,7 +295,7 @@
 #define OSMO_STRBUF_APPEND_NOLEN(STRBUF, func, args...) do { \
if (!(STRBUF).pos) \
(STRBUF).pos = (STRBUF).buf; \
-   size_t _sb_remain = (STRBUF).buf ? (STRBUF).len - ((STRBUF).pos 
- (STRBUF).buf) : 0; \
+   size_t _sb_remain = OSMO_STRBUF_REMAIN(STRBUF); \
if (_sb_remain) { \
func((STRBUF).pos, _sb_remain, ##args); \
} \

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35206?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6f2991125882bff948708bbb4ae218f9f3d1e50c
Gerrit-Change-Number: 35206
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-MessageType: newchange