diff --git a/lib/libc/net/nscache.c b/lib/libc/net/nscache.c --- a/lib/libc/net/nscache.c +++ b/lib/libc/net/nscache.c @@ -107,8 +107,8 @@ do { connection = __open_cached_connection(¶ms); if (connection == NULL) { - res = -1; - break; + free(buffer); + return (NS_UNAVAIL); } res = __cached_read(connection, cache_info->entry_name, cache_data->key, cache_data->key_size, buffer, @@ -317,11 +317,11 @@ __close_cached_mp_read_session(rs); rs = INVALID_CACHED_MP_READ_SESSION; cache_info->set_mp_rs_func(rs); - return (res == -1 ? NS_RETURN : NS_UNAVAIL); + return (res == 1 ? NS_NOTFOUND : NS_UNAVAIL); } free(buffer); - return (res == 0 ? NS_SUCCESS : NS_NOTFOUND); + return (NS_SUCCESS); } int diff --git a/lib/libc/net/nscachedcli.c b/lib/libc/net/nscachedcli.c --- a/lib/libc/net/nscachedcli.c +++ b/lib/libc/net/nscachedcli.c @@ -538,7 +538,7 @@ goto fin; if (rec_error_code != 0) { - error_code = rec_error_code; + error_code = -rec_error_code; goto fin; }