diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-10-11 17:04:15 +0200 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2019-10-18 09:20:58 +0000 |
commit | c85f773640965066ce5488f0be291fc69065a50b (patch) | |
tree | 787379663faca3af8bdf872f85537ee3269b34da /src | |
parent | 0fd0fe61fa1d20d3f8fbd04c70c60db63bcbe045 (diff) |
tdef: Return correct snprintf value for osmo_tdef_range_str_buf()
len provides extra information in the case the buffer was too small,
because it tells the caller "the number of characters (excluding the
terminating null byte) which would have been written to the final
string if enough space had been available" (man
snprintf).
Change-Id: Icafe559e19a92e2ae72fdd0dd2d9a394b1eda878
Diffstat (limited to 'src')
-rw-r--r-- | src/tdef.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -256,7 +256,9 @@ bool osmo_tdef_val_in_range(struct osmo_tdef *tdef, unsigned long new_val) * \param[in] buf The buffer where the string representation is stored. * \param[in] buf_len Length of buffer in bytes. * \param[in] tdef Timer entry from a timer definition table. - * \return The number of characters printed on success, negative on error. See snprintf(). + * \return The number of characters printed on success (or number of characters + * which would have been written to the final string if enough space + * had been available), negative on error. See snprintf(). */ int osmo_tdef_range_str_buf(char *buf, size_t buf_len, struct osmo_tdef *t) { @@ -275,7 +277,7 @@ int osmo_tdef_range_str_buf(char *buf, size_t buf_len, struct osmo_tdef *t) if (ret < 0) return ret; OSMO_SNPRINTF_RET(ret, rem, offset, len); - return ret; + return len; } /*! Using osmo_tdef for osmo_fsm_inst: find a given state's osmo_tdef_state_timeout entry. |