mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-08-05 21:06:19 -04:00
Fix all the compilation warnings #9
This commit is contained in:
parent
09ee99a282
commit
ca74a559c5
@ -246,7 +246,7 @@ namespace util
|
|||||||
static inline
|
static inline
|
||||||
int write_n(int fd, const char* buf, size_t length)
|
int write_n(int fd, const char* buf, size_t length)
|
||||||
{
|
{
|
||||||
int nwritten = 0;
|
size_t nwritten = 0;
|
||||||
while (nwritten < length) {
|
while (nwritten < length) {
|
||||||
int written = write(fd, buf + nwritten, length - nwritten);
|
int written = write(fd, buf + nwritten, length - nwritten);
|
||||||
if (written == -1) return -1;
|
if (written == -1) return -1;
|
||||||
@ -311,7 +311,7 @@ namespace util
|
|||||||
static inline int read_all(int fd, Buffer& buf)
|
static inline int read_all(int fd, Buffer& buf)
|
||||||
{
|
{
|
||||||
size_t orig_size = buf.size();
|
size_t orig_size = buf.size();
|
||||||
size_t increment = orig_size;
|
int increment = orig_size;
|
||||||
auto buffer = buf.data();
|
auto buffer = buf.data();
|
||||||
int total_bytes_read = 0;
|
int total_bytes_read = 0;
|
||||||
|
|
||||||
@ -1409,6 +1409,7 @@ namespace detail {
|
|||||||
// at all, using select() or threads is unnecessary.
|
// at all, using select() or threads is unnecessary.
|
||||||
auto hndls = {stream_->input(), stream_->output(), stream_->error()};
|
auto hndls = {stream_->input(), stream_->output(), stream_->error()};
|
||||||
int count = std::count(std::begin(hndls), std::end(hndls), nullptr);
|
int count = std::count(std::begin(hndls), std::end(hndls), nullptr);
|
||||||
|
const int len_conv = length;
|
||||||
|
|
||||||
if (count >= 2) {
|
if (count >= 2) {
|
||||||
OutBuffer obuf;
|
OutBuffer obuf;
|
||||||
@ -1416,7 +1417,7 @@ namespace detail {
|
|||||||
if (stream_->input()) {
|
if (stream_->input()) {
|
||||||
if (msg) {
|
if (msg) {
|
||||||
int wbytes = std::fwrite(msg, sizeof(char), length, stream_->input());
|
int wbytes = std::fwrite(msg, sizeof(char), length, stream_->input());
|
||||||
if (wbytes < length) {
|
if (wbytes < len_conv) {
|
||||||
if (errno != EPIPE && errno != EINVAL) {
|
if (errno != EPIPE && errno != EINVAL) {
|
||||||
throw OSError("fwrite error", errno);
|
throw OSError("fwrite error", errno);
|
||||||
}
|
}
|
||||||
@ -1472,6 +1473,7 @@ namespace detail {
|
|||||||
OutBuffer obuf;
|
OutBuffer obuf;
|
||||||
ErrBuffer ebuf;
|
ErrBuffer ebuf;
|
||||||
std::future<int> out_fut, err_fut;
|
std::future<int> out_fut, err_fut;
|
||||||
|
const int length_conv = length;
|
||||||
|
|
||||||
if (stream_->output()) {
|
if (stream_->output()) {
|
||||||
obuf.add_cap(out_buf_cap_);
|
obuf.add_cap(out_buf_cap_);
|
||||||
@ -1492,7 +1494,7 @@ namespace detail {
|
|||||||
if (stream_->input()) {
|
if (stream_->input()) {
|
||||||
if (msg) {
|
if (msg) {
|
||||||
int wbytes = std::fwrite(msg, sizeof(char), length, stream_->input());
|
int wbytes = std::fwrite(msg, sizeof(char), length, stream_->input());
|
||||||
if (wbytes < length) {
|
if (wbytes < length_conv) {
|
||||||
if (errno != EPIPE && errno != EINVAL) {
|
if (errno != EPIPE && errno != EINVAL) {
|
||||||
throw OSError("fwrite error", errno);
|
throw OSError("fwrite error", errno);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ void test_cat_file_redirection()
|
|||||||
auto p = sp::Popen({"cat", "-"}, sp::input{sp::PIPE}, sp::output{"cat_fredirect.txt"});
|
auto p = sp::Popen({"cat", "-"}, sp::input{sp::PIPE}, sp::output{"cat_fredirect.txt"});
|
||||||
auto msg = "through stdin to stdout";
|
auto msg = "through stdin to stdout";
|
||||||
int wr_bytes = p.send(msg, strlen(msg));
|
int wr_bytes = p.send(msg, strlen(msg));
|
||||||
assert (wr_bytes == strlen(msg));
|
assert (wr_bytes == (int)strlen(msg));
|
||||||
std::cout << "END_TEST" << std::endl;
|
std::cout << "END_TEST" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user