Mir

Merge lp:~raof/mir/from-the-neglected-branches-files into lp:mir

Proposed by Chris Halse Rogers
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 1890
Proposed branch: lp:~raof/mir/from-the-neglected-branches-files
Merge into: lp:mir
Diff against target: 185 lines (+32/-29)
5 files modified
tests/mir_test/pipe.cpp (+4/-3)
tests/mir_test/popen.cpp (+4/-5)
tests/mir_test_framework/cross_process_sync.cpp (+17/-17)
tests/mir_test_framework/process.cpp (+5/-3)
tests/mir_test_framework/stubbed_server_configuration.cpp (+2/-1)
To merge this branch: bzr merge lp:~raof/mir/from-the-neglected-branches-files
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve
Daniel van Vugt Approve
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+233150@code.launchpad.net

Commit message

Use std::system_error in preference to std::runtime_error for system errors.

Description of the change

One from the what-do-I-have-here-thats'-not-merged files:

Use more descriptive exception types in a couple of places.

Should be a straightforward, minor, improvement.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

(1) The third constructor parameter is unnecessary if you're not going to provide any more rich information. You'd get just as useful a string by omitting it and letting the system get an error message (like strerror?):
19 + boost::enable_error_info(std::system_error(errno,
20 + std::system_category(),
21 + "Failed to create pipe")));

(2) Unused #include?... tests/mir_test_framework/udev_environment.cpp

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

looks good to me

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good overall, but as Daniel mentioned:

194 +#include <system_error>

Unused include.

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) :
review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/mir_test/pipe.cpp'
--- tests/mir_test/pipe.cpp 2013-07-02 15:44:55 +0000
+++ tests/mir_test/pipe.cpp 2014-09-04 06:25:40 +0000
@@ -21,7 +21,7 @@
21#include <boost/throw_exception.hpp>21#include <boost/throw_exception.hpp>
22#include <boost/exception/errinfo_errno.hpp>22#include <boost/exception/errinfo_errno.hpp>
2323
24#include <stdexcept>24#include <system_error>
2525
26#include <unistd.h>26#include <unistd.h>
2727
@@ -32,8 +32,9 @@
32 if (pipe(pipefd))32 if (pipe(pipefd))
33 {33 {
34 BOOST_THROW_EXCEPTION(34 BOOST_THROW_EXCEPTION(
35 boost::enable_error_info(std::runtime_error("Failed to create pipe"))35 boost::enable_error_info(std::system_error(errno,
36 << boost::errinfo_errno(errno));36 std::system_category(),
37 "Failed to create pipe")));
37 }38 }
38}39}
3940
4041
=== modified file 'tests/mir_test/popen.cpp'
--- tests/mir_test/popen.cpp 2014-04-30 21:37:07 +0000
+++ tests/mir_test/popen.cpp 2014-09-04 06:25:40 +0000
@@ -23,7 +23,7 @@
23#include <boost/iostreams/device/file_descriptor.hpp>23#include <boost/iostreams/device/file_descriptor.hpp>
24#include <boost/iostreams/stream_buffer.hpp>24#include <boost/iostreams/stream_buffer.hpp>
2525
26#include <stdexcept>26#include <system_error>
2727
28namespace mt = mir::test;28namespace mt = mir::test;
29namespace io = boost::iostreams;29namespace io = boost::iostreams;
@@ -35,16 +35,15 @@
35 if (raw_stream == nullptr)35 if (raw_stream == nullptr)
36 {36 {
37 BOOST_THROW_EXCEPTION(37 BOOST_THROW_EXCEPTION(
38 boost::enable_error_info(std::runtime_error("popen failed"))38 boost::enable_error_info(std::system_error(errno, std::system_category(), "popen failed")));
39 << boost::errinfo_errno(errno));
40 }39 }
4140
42 int fd = fileno(raw_stream);41 int fd = fileno(raw_stream);
43 if (fd == -1)42 if (fd == -1)
44 {43 {
45 BOOST_THROW_EXCEPTION(44 BOOST_THROW_EXCEPTION(
46 boost::enable_error_info(std::runtime_error("invalid file stream"))45 boost::enable_error_info(
47 << boost::errinfo_errno(errno));46 std::system_error(errno, std::system_category(), "invalid file stream")));
48 }47 }
49 auto raw = new io::stream_buffer<io::file_descriptor_source>{48 auto raw = new io::stream_buffer<io::file_descriptor_source>{
50 fd, io::never_close_handle};49 fd, io::never_close_handle};
5150
=== modified file 'tests/mir_test_framework/cross_process_sync.cpp'
--- tests/mir_test_framework/cross_process_sync.cpp 2014-03-06 06:05:17 +0000
+++ tests/mir_test_framework/cross_process_sync.cpp 2014-09-04 06:25:40 +0000
@@ -18,8 +18,8 @@
1818
19#include "mir_test_framework/cross_process_sync.h"19#include "mir_test_framework/cross_process_sync.h"
2020
21#include <boost/exception/errinfo_errno.hpp>21#include <boost/exception/info.hpp>
2222#include <system_error>
23#include <poll.h>23#include <poll.h>
24#include <unistd.h>24#include <unistd.h>
2525
@@ -38,9 +38,9 @@
38{38{
39 if (::pipe(fds) < 0)39 if (::pipe(fds) < 0)
40 {40 {
41 BOOST_THROW_EXCEPTION(41 BOOST_THROW_EXCEPTION(std::system_error(errno,
42 ::boost::enable_error_info(std::runtime_error("Failed to create pipe"))42 std::system_category(),
43 << boost::errinfo_errno(errno));43 "Failed to create pipe"));
44 }44 }
45}45}
4646
@@ -81,9 +81,9 @@
8181
82 if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)82 if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)
83 {83 {
84 BOOST_THROW_EXCEPTION(84 BOOST_THROW_EXCEPTION(std::system_error(errno,
85 ::boost::enable_error_info(std::runtime_error("Error while polling pipe to become writable"))85 std::system_category(),
86 << boost::errinfo_errno(errno));86 "Error while polling pipe to become writable"));
87 }87 }
88 else if (rc == 0)88 else if (rc == 0)
89 {89 {
@@ -93,9 +93,9 @@
93 int value = 1;93 int value = 1;
94 if (sizeof(value) != write(fds[write_fd], std::addressof(value), sizeof(value)))94 if (sizeof(value) != write(fds[write_fd], std::addressof(value), sizeof(value)))
95 {95 {
96 BOOST_THROW_EXCEPTION(96 BOOST_THROW_EXCEPTION(std::system_error(errno,
97 ::boost::enable_error_info(std::runtime_error("Error while writing to pipe"))97 std::system_category(),
98 << boost::errinfo_errno(errno));98 "Error while writing to pipe"));
99 }99 }
100}100}
101101
@@ -112,9 +112,9 @@
112112
113 if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)113 if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)
114 {114 {
115 BOOST_THROW_EXCEPTION(115 BOOST_THROW_EXCEPTION(std::system_error(errno,
116 ::boost::enable_error_info(std::runtime_error("Error while polling pipe to become readable"))116 std::system_category(),
117 << boost::errinfo_errno(errno));117 "Error while polling pipe to become readable"));
118 }118 }
119 else if (rc == 0)119 else if (rc == 0)
120 {120 {
@@ -124,9 +124,9 @@
124 int value;124 int value;
125 if (sizeof(value) != read(fds[read_fd], std::addressof(value), sizeof(value)))125 if (sizeof(value) != read(fds[read_fd], std::addressof(value), sizeof(value)))
126 {126 {
127 BOOST_THROW_EXCEPTION(127 BOOST_THROW_EXCEPTION(std::system_error(errno,
128 ::boost::enable_error_info(std::runtime_error("Error while reading from pipe"))128 std::system_category(),
129 << boost::errinfo_errno(errno));129 "Error while reading from pipe"));
130 }130 }
131131
132 if (value != 1)132 if (value != 1)
133133
=== modified file 'tests/mir_test_framework/process.cpp'
--- tests/mir_test_framework/process.cpp 2014-04-10 22:23:27 +0000
+++ tests/mir_test_framework/process.cpp 2014-09-04 06:25:40 +0000
@@ -25,6 +25,7 @@
2525
26#include <boost/exception/errinfo_errno.hpp>26#include <boost/exception/errinfo_errno.hpp>
2727
28#include <system_error>
28#include <cassert>29#include <cassert>
29#include <chrono>30#include <chrono>
30#include <ostream>31#include <ostream>
@@ -45,10 +46,11 @@
45 if (::kill(pid, signum) != 0)46 if (::kill(pid, signum) != 0)
46 {47 {
47 BOOST_THROW_EXCEPTION(48 BOOST_THROW_EXCEPTION(
48 ::boost::enable_error_info(std::runtime_error("Failed to kill process."))49 ::boost::enable_error_info(std::system_error(errno,
50 std::system_category(),
51 "Failed to kill process."))
49 << errinfo_pid(pid)52 << errinfo_pid(pid)
50 << errinfo_signum(signum)53 << errinfo_signum(signum));
51 << boost::errinfo_errno(errno));
52 }54 }
53}55}
54}56}
5557
=== modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp'
--- tests/mir_test_framework/stubbed_server_configuration.cpp 2014-08-14 07:53:02 +0000
+++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-09-04 06:25:40 +0000
@@ -43,6 +43,7 @@
43#include "src/server/input/null_input_dispatcher.h"43#include "src/server/input/null_input_dispatcher.h"
44#include "src/server/input/null_input_targeter.h"44#include "src/server/input/null_input_targeter.h"
4545
46#include <system_error>
46#include <boost/exception/errinfo_errno.hpp>47#include <boost/exception/errinfo_errno.hpp>
47#include <boost/throw_exception.hpp>48#include <boost/throw_exception.hpp>
4849
@@ -72,7 +73,7 @@
72 if (fd < 0)73 if (fd < 0)
73 BOOST_THROW_EXCEPTION(74 BOOST_THROW_EXCEPTION(
74 boost::enable_error_info(75 boost::enable_error_info(
75 std::runtime_error("Failed to open dummy fd")) << boost::errinfo_errno(errno));76 std::system_error(errno, std::system_category(), "Failed to open dummy fd")));
76 }77 }
7778
78 std::shared_ptr<mg::NativeBuffer> native_buffer_handle() const override79 std::shared_ptr<mg::NativeBuffer> native_buffer_handle() const override

Subscribers

People subscribed via source and target branches