[SSSD] [PATCH] sss_atomic_write_s() return value is signed
Jakub Hrozek
jhrozek at redhat.com
Tue Dec 2 21:08:45 UTC 2014
Found when working on unit tests for the child code. Some callers of
sss_atomic_write_s() would treat the return value as unsigned (size_t)
while the function can return -1 on error.
-------------- next part --------------
>From 6a9b28f4a45f0d7a9a058d664acab6c95f35c178 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Sat, 29 Nov 2014 22:23:38 +0100
Subject: [PATCH] sss_atomic_write_s() return value is signed
---
src/providers/ad/ad_gpo_child.c | 2 +-
src/providers/ipa/selinux_child.c | 2 +-
src/providers/krb5/krb5_child.c | 2 +-
src/providers/ldap/ldap_child.c | 2 +-
src/responder/nss/nsssrv_mmap_cache.c | 8 ++++----
src/tools/sss_seed.c | 2 +-
src/tools/tools_mc_util.c | 9 ++++-----
src/util/child_common.c | 4 ++--
8 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/src/providers/ad/ad_gpo_child.c b/src/providers/ad/ad_gpo_child.c
index 4bb48c0479400ebeeca287acfcb1573c69a76b90..ceb2faeb65e797c5b8493cd4bbe95690d848f28d 100644
--- a/src/providers/ad/ad_gpo_child.c
+++ b/src/providers/ad/ad_gpo_child.c
@@ -663,7 +663,7 @@ main(int argc, const char *argv[])
ssize_t len = 0;
struct input_buffer *ibuf = NULL;
struct response *resp = NULL;
- size_t written;
+ ssize_t written;
struct poptOption long_options[] = {
POPT_AUTOHELP
diff --git a/src/providers/ipa/selinux_child.c b/src/providers/ipa/selinux_child.c
index a38ffcb26f890349f47478063103e603fe6304cf..cb6f96415690c3931be52167b6ccb7f081a52a6f 100644
--- a/src/providers/ipa/selinux_child.c
+++ b/src/providers/ipa/selinux_child.c
@@ -146,7 +146,7 @@ int main(int argc, const char *argv[])
ssize_t len = 0;
struct input_buffer *ibuf = NULL;
struct response *resp = NULL;
- size_t written;
+ ssize_t written;
struct poptOption long_options[] = {
POPT_AUTOHELP
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index 2c0a881864053d7428f64db77621417384afcfb6..e3e85186024832fb15b8c37237ab7bbe64ff2334 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -708,7 +708,7 @@ static errno_t k5c_attach_ccname_msg(struct krb5_req *kr)
static errno_t k5c_send_data(struct krb5_req *kr, int fd, errno_t error)
{
- size_t written;
+ ssize_t written;
uint8_t *buf;
size_t len;
int ret;
diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c
index a1e250c46fe1052849ab66f2d3158b7c7d143c51..e9aebf5a6319b5d848aadfb27061099fc153a7f6 100644
--- a/src/providers/ldap/ldap_child.c
+++ b/src/providers/ldap/ldap_child.c
@@ -581,7 +581,7 @@ int main(int argc, const char *argv[])
time_t expire_time = 0;
struct input_buffer *ibuf = NULL;
struct response *resp = NULL;
- size_t written;
+ ssize_t written;
struct poptOption long_options[] = {
POPT_AUTOHELP
diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c
index 41846d5656ab21b8595af607951b8f0a7e830bdc..2d159eb11add2014612c21d2061942cb1afa553c 100644
--- a/src/responder/nss/nsssrv_mmap_cache.c
+++ b/src/responder/nss/nsssrv_mmap_cache.c
@@ -969,7 +969,7 @@ static errno_t sss_mc_set_recycled(int fd)
struct sss_mc_header h;
off_t offset;
off_t pos;
- int ret;
+ ssize_t written;
offset = MC_PTR_DIFF(&h.status, &h);
@@ -980,12 +980,12 @@ static errno_t sss_mc_set_recycled(int fd)
}
errno = 0;
- ret = sss_atomic_write_s(fd, (uint8_t *)&w, sizeof(h.status));
- if (ret == -1) {
+ written = sss_atomic_write_s(fd, (uint8_t *)&w, sizeof(h.status));
+ if (written == -1) {
return errno;
}
- if (ret != sizeof(h.status)) {
+ if (written != sizeof(h.status)) {
/* Write error */
return EIO;
}
diff --git a/src/tools/sss_seed.c b/src/tools/sss_seed.c
index 0f8a76a61cb2a029015416a59d235a1c5d49deca..2cd6a57aa8ce33b052d1bb05414c0d1f60cdf798 100644
--- a/src/tools/sss_seed.c
+++ b/src/tools/sss_seed.c
@@ -62,7 +62,7 @@ struct seed_ctx {
static int seed_prompt(const char *req)
{
- size_t len = 0;
+ ssize_t len = 0;
size_t i = 0;
char *prompt = NULL;
int ret = EOK;
diff --git a/src/tools/tools_mc_util.c b/src/tools/tools_mc_util.c
index 2d6f3fb40d787f61f7b8c75b8ea2a007c4d29c10..9634b86e248a1937f68939c5a8d8a6301780a566 100644
--- a/src/tools/tools_mc_util.c
+++ b/src/tools/tools_mc_util.c
@@ -37,8 +37,7 @@ static errno_t sss_mc_set_recycled(int fd)
struct sss_mc_header h;
off_t offset;
off_t pos;
- int ret;
-
+ ssize_t written;
offset = MC_PTR_DIFF(&h.status, &h);
@@ -49,12 +48,12 @@ static errno_t sss_mc_set_recycled(int fd)
}
errno = 0;
- ret = sss_atomic_write_s(fd, (uint8_t *)&w, sizeof(h.status));
- if (ret == -1) {
+ written = sss_atomic_write_s(fd, (uint8_t *)&w, sizeof(h.status));
+ if (written == -1) {
return errno;
}
- if (ret != sizeof(h.status)) {
+ if (written != sizeof(h.status)) {
/* Write error */
return EIO;
}
diff --git a/src/util/child_common.c b/src/util/child_common.c
index 20c7b0ddcfb4fdb5c00560cb11670ffc95bc4b91..3b159f9d9a6144d348369ee39a5cca93fcd9c46e 100644
--- a/src/util/child_common.c
+++ b/src/util/child_common.c
@@ -323,7 +323,7 @@ struct write_pipe_state {
int fd;
uint8_t *buf;
size_t len;
- size_t written;
+ ssize_t written;
};
static void write_pipe_handler(struct tevent_context *ev,
@@ -388,7 +388,7 @@ static void write_pipe_handler(struct tevent_context *ev,
}
if (state->len != state->written) {
- DEBUG(SSSDBG_CRIT_FAILURE, "Wrote %zu bytes, expected %zu\n",
+ DEBUG(SSSDBG_CRIT_FAILURE, "Wrote %zd bytes, expected %zu\n",
state->written, state->len);
tevent_req_error(req, EIO);
return;
--
1.9.3
More information about the sssd-devel
mailing list