Skip to content

Commit 1e1cb37

Browse files
committed
Silent warnings -Wunused-result of g++-4.7
Pointed out by Joachim: | Date: Sun, 10 Jun 2012 17:43:27 +0200 | From: Joachim Reichel <[email protected]> | To: Laurent Rineau <[email protected]> | Subject: silence warnings caused by -Wunused-result | | Hi Laurent, | | your changes in 61145 and 61146 to silence the warnings in the Geomview | package don't work with gcc 4.7.0 and -Wunused-result. I still see | | src/CGAL/Geomview_stream.cpp:148:35: warning: ignoring return value of | 'ssize_t read(int, void*, size_t)', declared with attribute | warn_unused_result [-Wunused-result] | | Maybe one really needs to use | | int result = read(...) | (void) result; | | to silence the warnings. | | Joachim I have not been able to reproduce that with my compiler "g++-trunk (GCC) 4.8.0 20120611 (experimental)".
1 parent 7f08b8b commit 1e1cb37

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Geomview/src/CGAL/Geomview_stream.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ void Geomview_stream::setup_geomview(const char *machine, const char *login)
145145
*this << "(echo \"CGAL-3D\")";
146146

147147
char inbuf[10];
148-
(void)::read(in, inbuf, 7);
148+
std::size_t retread=::read(in, inbuf, 7);
149+
(void)retread;
149150

150151
if (std::strncmp(inbuf, "started", 7) == 0)
151152
{
@@ -154,7 +155,8 @@ void Geomview_stream::setup_geomview(const char *machine, const char *login)
154155
// << "compulsory anymore, since CGAL 2.3" << std::endl;
155156

156157
// Then the next one is supposed to be CGAL-3D.
157-
(void)::read(in, inbuf, 7);
158+
retread=::read(in, inbuf, 7);
159+
(void)retread;
158160
if (std::strncmp(inbuf, "CGAL-3D", 7) != 0)
159161
std::cerr << "Unexpected string from Geomview !" << std::endl;
160162
}
@@ -172,7 +174,8 @@ void Geomview_stream::setup_geomview(const char *machine, const char *login)
172174
// Old original version
173175
char inbuf[10];
174176
// Waits for "started" from the .geomview file.
175-
(void)::read(in, inbuf, 7);
177+
retread=::read(in, inbuf, 7);
178+
(void)retread;
176179
#endif
177180

178181
std::cout << "done." << std::endl;
@@ -230,7 +233,8 @@ Geomview_stream::operator<<(int i)
230233
// we write raw binary data to the stream.
231234
int num = i;
232235
I_swap_to_big_endian(num);
233-
(void)::write(out, (char*)&num, sizeof(num));
236+
std::size_t retwrite=::write(out, (char*)&num, sizeof(num));
237+
(void)retwrite;
234238
trace(i);
235239
} else {
236240
// transform the int in a character sequence and put whitespace around
@@ -250,7 +254,8 @@ Geomview_stream::operator<<(unsigned int i)
250254
// we write raw binary data to the stream.
251255
unsigned int num = i;
252256
I_swap_to_big_endian(num);
253-
(void)::write(out, (char*)&num, sizeof(num));
257+
std::size_t retwrite=::write(out, (char*)&num, sizeof(num));
258+
(void)retwrite;
254259
trace(i);
255260
} else {
256261
// transform the int in a character sequence and put whitespace around
@@ -281,7 +286,8 @@ Geomview_stream::operator<<(double d)
281286
if (get_binary_mode()) {
282287
float num = d;
283288
I_swap_to_big_endian(num);
284-
(void)::write(out, (char*)&num, sizeof(num));
289+
std::size_t retwrite= ::write(out, (char*)&num, sizeof(num));
290+
(void)retwrite;
285291
trace(f);
286292
} else {
287293
// 'copy' the float in a string and append a blank
@@ -468,13 +474,15 @@ Geomview_stream::operator>>(char *expr)
468474
{
469475
// Skip whitespaces
470476
do {
471-
(void)::read(in, expr, 1);
477+
std::size_t retread=::read(in, expr, 1);
478+
(void)retread;
472479
} while (expr[0] != '(');
473480

474481
int pcount = 1;
475482
int i = 1;
476483
while (1) {
477-
(void)::read(in, &expr[i], 1);
484+
std::size_t retread=::read(in, &expr[i], 1);
485+
(void)retread;
478486
if (expr[i] == ')'){
479487
pcount--;
480488
} else if (expr[i] == '('){

0 commit comments

Comments
 (0)