[PATCH 2/2] ipa: Return -errno instead of -1 in ipa_send

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/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Mon Dec 22 09:58:46 UTC 2014


Currently, the ipa_send function returns -1 in one execution branch
to indicate an error and -EIO in another. This is not consistent and
can lead to a misinterpretation of the error code, since -1 is -EPERM
and in general, EPERM is not returned by write(2).

This patch changes the return code to -errno instead of -1 for the
case that write(2) fails for same reason. So -rc is always a sensible
error value if there is a failure.

Sponsored-by: On-Waves ehf
---
 src/gsm/ipa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index ce98f08..7cff1e8 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -199,7 +199,7 @@ int ipa_send(int fd, const void *msg, size_t msglen)
 
 	ret = write(fd, msg, msglen);
 	if (ret < 0)
-		return ret;
+		return -errno;
 	if (ret < msglen) {
 		LOGP(DLINP, LOGL_ERROR, "ipa_send: short write\n");
 		return -EIO;
-- 
1.9.1




More information about the OpenBSC mailing list