Skip to content

Commit b703f95

Browse files
author
Divan Visagie
committed
Merge pull request d5#24 from tojocky/master
resolve warnings with clang
2 parents b3af2e0 + 1596092 commit b703f95

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

native/fs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ namespace native
360360
public:
361361
static bool read(const std::string& path, std::function<void(const std::string& str, error e)> callback)
362362
{
363-
if(!fs::open(path.c_str(), fs::read_only, 0, [=](fs::file_handle fd, error e) {
363+
return fs::open(path.c_str(), fs::read_only, 0, [=](fs::file_handle fd, error e) {
364364
if(e)
365365
{
366366
callback(std::string(), e);
@@ -373,12 +373,12 @@ namespace native
373373
callback(std::string(), error(uv_last_error(uv_default_loop())));
374374
}
375375
}
376-
})) return false;
376+
});
377377
}
378378

379379
static bool write(const std::string& path, const std::string& str, std::function<void(int nwritten, error e)> callback)
380380
{
381-
if(!fs::open(path.c_str(), fs::write_only|fs::create, 0664, [=](fs::file_handle fd, error e) {
381+
return fs::open(path.c_str(), fs::write_only|fs::create, 0664, [=](fs::file_handle fd, error e) {
382382
if(e)
383383
{
384384
callback(0, e);
@@ -391,7 +391,7 @@ namespace native
391391
callback(0, error(uv_last_error(uv_default_loop())));
392392
}
393393
}
394-
})) return false;
394+
});
395395
}
396396
};
397397
}

native/stream.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "handle.h"
77
#include "callback.h"
88

9+
#include <algorithm>
10+
911
namespace native
1012
{
1113
namespace base
@@ -36,22 +38,15 @@ namespace native
3638
return read_start<0>(callback);
3739
}
3840

39-
template<int max_alloc_size>
41+
template<size_t max_alloc_size>
4042
bool read_start(std::function<void(const char* buf, ssize_t len)> callback)
4143
{
4244
callbacks::store(get()->data, native::internal::uv_cid_read_start, callback);
4345

4446
return uv_read_start(get<uv_stream_t>(),
4547
[](uv_handle_t*, size_t suggested_size){
46-
if(!max_alloc_size)
47-
{
48-
return uv_buf_t { new char[suggested_size], suggested_size };
49-
}
50-
else
51-
{
52-
auto size = max_alloc_size > suggested_size ? suggested_size : max_alloc_size;
53-
return uv_buf_t { new char[size], size };
54-
}
48+
auto size = std::max(suggested_size, max_alloc_size);
49+
return uv_buf_t { new char[size], size };
5550
},
5651
[](uv_stream_t* s, ssize_t nread, uv_buf_t buf){
5752
if(nread < 0)

0 commit comments

Comments
 (0)