This commit is contained in:
Michele Caini 2022-04-08 08:39:02 +02:00
parent 1c3dca1398
commit db6f17541a
5 changed files with 24 additions and 22 deletions

View File

@ -86,7 +86,7 @@ public:
* @return True if the handle is active, false otherwise.
*/
bool active() const UVW_NOEXCEPT {
return !(uv_is_active(as_uv_handle()) == 0);
return !!uv_is_active(as_uv_handle());
}
/**
@ -98,7 +98,7 @@ public:
* @return True if the handle is closing or closed, false otherwise.
*/
bool closing() const UVW_NOEXCEPT {
return !(uv_is_closing(as_uv_handle()) == 0);
return !!uv_is_closing(as_uv_handle());
}
/**
@ -140,7 +140,7 @@ public:
* @return True if the handle referenced, false otherwise.
*/
bool referenced() const UVW_NOEXCEPT {
return !(uv_has_ref(as_uv_handle()) == 0);
return !!uv_has_ref(as_uv_handle());
}
/**
@ -160,12 +160,13 @@ public:
* udp handles on Windows.<br/>
* Note that Linux will return double the size of the original set value.
*
* @return The size of the send buffer, 0 in case of errors.
* @return The size of the send buffer, the underlying return value in case
* of errors.
*/
int send_buffer_size() {
int value = 0;
auto err = uv_send_buffer_size(as_uv_handle(), &value);
return err ? 0 : value;
return err ? err : value;
}
/**
@ -177,10 +178,10 @@ public:
* udp handles on Windows.<br/>
* Note that Linux will set double the size.
*
* @return True in case of success, false otherwise.
* @return Underlying return value.
*/
bool send_buffer_size(int value) {
return (0 == uv_send_buffer_size(as_uv_handle(), &value));
int send_buffer_size(int value) {
return uv_send_buffer_size(as_uv_handle(), &value);
}
/**
@ -192,12 +193,13 @@ public:
* udp handles on Windows.<br/>
* Note that Linux will return double the size of the original set value.
*
* @return The size of the receive buffer, 0 in case of errors.
* @return The size of the receive buffer, the underlying return value in
* case of errors.
*/
int recv_buffer_size() {
int value = 0;
auto err = uv_recv_buffer_size(as_uv_handle(), &value);
return err ? 0 : value;
return err ? err : value;
}
/**
@ -209,10 +211,10 @@ public:
* udp handles on Windows.<br/>
* Note that Linux will set double the size.
*
* @return True in case of success, false otherwise.
* @return Underlying return value.
*/
bool recv_buffer_size(int value) {
return (0 == uv_recv_buffer_size(as_uv_handle(), &value));
int recv_buffer_size(int value) {
return uv_recv_buffer_size(as_uv_handle(), &value);
}
/**

View File

@ -68,7 +68,7 @@ int loop::run(run_mode mode) UVW_NOEXCEPT {
}
UVW_INLINE bool loop::alive() const UVW_NOEXCEPT {
return !(uv_loop_alive(uv_loop.get()) == 0);
return !!uv_loop_alive(uv_loop.get());
}
UVW_INLINE void loop::stop() UVW_NOEXCEPT {

View File

@ -55,8 +55,8 @@ UVW_INLINE handle_type pipe_handle::receive() UVW_NOEXCEPT {
return utilities::guess_handle(category);
}
UVW_INLINE bool pipe_handle::chmod(chmod_flags flags) UVW_NOEXCEPT {
return (0 == uv_pipe_chmod(raw(), static_cast<uv_poll_event>(flags)));
UVW_INLINE int pipe_handle::chmod(chmod_flags flags) UVW_NOEXCEPT {
return uv_pipe_chmod(raw(), static_cast<uv_poll_event>(flags));
}
} // namespace uvw

View File

@ -145,9 +145,9 @@ public:
* for further details.
*
* @param flags A valid set of flags.
* @return True in case of success, false otherwise.
* @return Underlying return value.
*/
bool chmod(chmod_flags flags) UVW_NOEXCEPT;
int chmod(chmod_flags flags) UVW_NOEXCEPT;
private:
bool ipc;

View File

@ -37,11 +37,11 @@ TEST(Handle, Functionalities) {
ASSERT_NE(handle->size(), static_cast<decltype(handle->size())>(0));
ASSERT_EQ(handle->send_buffer_size(), static_cast<decltype(handle->send_buffer_size())>(0));
ASSERT_FALSE(handle->send_buffer_size(0));
ASSERT_LT(handle->send_buffer_size(), 0);
ASSERT_NE(0, handle->send_buffer_size(0));
ASSERT_EQ(handle->recv_buffer_size(), static_cast<decltype(handle->recv_buffer_size())>(0));
ASSERT_FALSE(handle->recv_buffer_size(0));
ASSERT_LT(handle->recv_buffer_size(), 0);
ASSERT_NE(0, handle->recv_buffer_size(0));
ASSERT_NO_THROW(handle->fd());
}