From 98ed3393cdfdf35ad0bb79f454474f2b27bf3d56 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 28 Mar 2019 13:26:53 +0100 Subject: osmo_escape_str_buf: Always copy, don't return input string pointer osmo_escape_str_buf() used to have the somewhat odd semantics that if no escaping was needed, it would return the original pointer without making any copy to the output buffer. While this seems like an elegant optimization, it is a very strange behavior and it works differently than all of our other *_buf() functions. Let's unify the API and turn osmo_escape_str_buf() into a strlcpy() if no escaping is needed. Change-Id: I3a02bdb27008a73101c2db41ac04248960ed4064 --- include/osmocom/core/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/osmocom') diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 16159d3d..e3728cd0 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -137,7 +137,7 @@ bool osmo_identifier_valid(const char *str); bool osmo_separated_identifiers_valid(const char *str, const char *sep_chars); const char *osmo_escape_str(const char *str, int len); -const char *osmo_escape_str_buf(const char *str, int in_len, char *buf, size_t bufsize); +char *osmo_escape_str_buf(const char *str, int in_len, char *buf, size_t bufsize); const char *osmo_quote_str(const char *str, int in_len); const char *osmo_quote_str_buf(const char *str, int in_len, char *buf, size_t bufsize); -- cgit v1.2.3