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
1=== modified file 'tests/mir_test/pipe.cpp'
2--- tests/mir_test/pipe.cpp 2013-07-02 15:44:55 +0000
3+++ tests/mir_test/pipe.cpp 2014-09-04 06:25:40 +0000
4@@ -21,7 +21,7 @@
5 #include <boost/throw_exception.hpp>
6 #include <boost/exception/errinfo_errno.hpp>
7
8-#include <stdexcept>
9+#include <system_error>
10
11 #include <unistd.h>
12
13@@ -32,8 +32,9 @@
14 if (pipe(pipefd))
15 {
16 BOOST_THROW_EXCEPTION(
17- boost::enable_error_info(std::runtime_error("Failed to create pipe"))
18- << boost::errinfo_errno(errno));
19+ boost::enable_error_info(std::system_error(errno,
20+ std::system_category(),
21+ "Failed to create pipe")));
22 }
23 }
24
25
26=== modified file 'tests/mir_test/popen.cpp'
27--- tests/mir_test/popen.cpp 2014-04-30 21:37:07 +0000
28+++ tests/mir_test/popen.cpp 2014-09-04 06:25:40 +0000
29@@ -23,7 +23,7 @@
30 #include <boost/iostreams/device/file_descriptor.hpp>
31 #include <boost/iostreams/stream_buffer.hpp>
32
33-#include <stdexcept>
34+#include <system_error>
35
36 namespace mt = mir::test;
37 namespace io = boost::iostreams;
38@@ -35,16 +35,15 @@
39 if (raw_stream == nullptr)
40 {
41 BOOST_THROW_EXCEPTION(
42- boost::enable_error_info(std::runtime_error("popen failed"))
43- << boost::errinfo_errno(errno));
44+ boost::enable_error_info(std::system_error(errno, std::system_category(), "popen failed")));
45 }
46
47 int fd = fileno(raw_stream);
48 if (fd == -1)
49 {
50 BOOST_THROW_EXCEPTION(
51- boost::enable_error_info(std::runtime_error("invalid file stream"))
52- << boost::errinfo_errno(errno));
53+ boost::enable_error_info(
54+ std::system_error(errno, std::system_category(), "invalid file stream")));
55 }
56 auto raw = new io::stream_buffer<io::file_descriptor_source>{
57 fd, io::never_close_handle};
58
59=== modified file 'tests/mir_test_framework/cross_process_sync.cpp'
60--- tests/mir_test_framework/cross_process_sync.cpp 2014-03-06 06:05:17 +0000
61+++ tests/mir_test_framework/cross_process_sync.cpp 2014-09-04 06:25:40 +0000
62@@ -18,8 +18,8 @@
63
64 #include "mir_test_framework/cross_process_sync.h"
65
66-#include <boost/exception/errinfo_errno.hpp>
67-
68+#include <boost/exception/info.hpp>
69+#include <system_error>
70 #include <poll.h>
71 #include <unistd.h>
72
73@@ -38,9 +38,9 @@
74 {
75 if (::pipe(fds) < 0)
76 {
77- BOOST_THROW_EXCEPTION(
78- ::boost::enable_error_info(std::runtime_error("Failed to create pipe"))
79- << boost::errinfo_errno(errno));
80+ BOOST_THROW_EXCEPTION(std::system_error(errno,
81+ std::system_category(),
82+ "Failed to create pipe"));
83 }
84 }
85
86@@ -81,9 +81,9 @@
87
88 if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)
89 {
90- BOOST_THROW_EXCEPTION(
91- ::boost::enable_error_info(std::runtime_error("Error while polling pipe to become writable"))
92- << boost::errinfo_errno(errno));
93+ BOOST_THROW_EXCEPTION(std::system_error(errno,
94+ std::system_category(),
95+ "Error while polling pipe to become writable"));
96 }
97 else if (rc == 0)
98 {
99@@ -93,9 +93,9 @@
100 int value = 1;
101 if (sizeof(value) != write(fds[write_fd], std::addressof(value), sizeof(value)))
102 {
103- BOOST_THROW_EXCEPTION(
104- ::boost::enable_error_info(std::runtime_error("Error while writing to pipe"))
105- << boost::errinfo_errno(errno));
106+ BOOST_THROW_EXCEPTION(std::system_error(errno,
107+ std::system_category(),
108+ "Error while writing to pipe"));
109 }
110 }
111
112@@ -112,9 +112,9 @@
113
114 if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)
115 {
116- BOOST_THROW_EXCEPTION(
117- ::boost::enable_error_info(std::runtime_error("Error while polling pipe to become readable"))
118- << boost::errinfo_errno(errno));
119+ BOOST_THROW_EXCEPTION(std::system_error(errno,
120+ std::system_category(),
121+ "Error while polling pipe to become readable"));
122 }
123 else if (rc == 0)
124 {
125@@ -124,9 +124,9 @@
126 int value;
127 if (sizeof(value) != read(fds[read_fd], std::addressof(value), sizeof(value)))
128 {
129- BOOST_THROW_EXCEPTION(
130- ::boost::enable_error_info(std::runtime_error("Error while reading from pipe"))
131- << boost::errinfo_errno(errno));
132+ BOOST_THROW_EXCEPTION(std::system_error(errno,
133+ std::system_category(),
134+ "Error while reading from pipe"));
135 }
136
137 if (value != 1)
138
139=== modified file 'tests/mir_test_framework/process.cpp'
140--- tests/mir_test_framework/process.cpp 2014-04-10 22:23:27 +0000
141+++ tests/mir_test_framework/process.cpp 2014-09-04 06:25:40 +0000
142@@ -25,6 +25,7 @@
143
144 #include <boost/exception/errinfo_errno.hpp>
145
146+#include <system_error>
147 #include <cassert>
148 #include <chrono>
149 #include <ostream>
150@@ -45,10 +46,11 @@
151 if (::kill(pid, signum) != 0)
152 {
153 BOOST_THROW_EXCEPTION(
154- ::boost::enable_error_info(std::runtime_error("Failed to kill process."))
155+ ::boost::enable_error_info(std::system_error(errno,
156+ std::system_category(),
157+ "Failed to kill process."))
158 << errinfo_pid(pid)
159- << errinfo_signum(signum)
160- << boost::errinfo_errno(errno));
161+ << errinfo_signum(signum));
162 }
163 }
164 }
165
166=== modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp'
167--- tests/mir_test_framework/stubbed_server_configuration.cpp 2014-08-14 07:53:02 +0000
168+++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-09-04 06:25:40 +0000
169@@ -43,6 +43,7 @@
170 #include "src/server/input/null_input_dispatcher.h"
171 #include "src/server/input/null_input_targeter.h"
172
173+#include <system_error>
174 #include <boost/exception/errinfo_errno.hpp>
175 #include <boost/throw_exception.hpp>
176
177@@ -72,7 +73,7 @@
178 if (fd < 0)
179 BOOST_THROW_EXCEPTION(
180 boost::enable_error_info(
181- std::runtime_error("Failed to open dummy fd")) << boost::errinfo_errno(errno));
182+ std::system_error(errno, std::system_category(), "Failed to open dummy fd")));
183 }
184
185 std::shared_ptr<mg::NativeBuffer> native_buffer_handle() const override

Subscribers

People subscribed via source and target branches