Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit26fcc03

Browse files
committed
Applied some minor fixes discovered by Coverity.
1 parent657b5a2 commit26fcc03

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

‎README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Modern C++ network programming libraries.
66
..image::https://travis-ci.org/cpp-netlib/cpp-netlib.svg?branch=master
77
:target:https://travis-ci.org/cpp-netlib/cpp-netlib
88

9+
..image::https://scan.coverity.com/projects/6714/badge.svg
10+
:target:https://scan.coverity.com/projects/cpp-netlib
11+
912
Join us on Slack: http://slack.cpp-netlib.org/
1013

1114
Subscribe to the mailing list: https://groups.google.com/forum/#!forum/cpp-netlib

‎boost/network/protocol/http/server/async_connection.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ struct async_connection
199199
headers_in_progress(false) {
200200
(void)ctx;
201201
new_start = read_buffer_.begin();
202+
data_end = read_buffer_.begin();
202203
}
203204

204205
~async_connection()throw() {

‎libs/network/example/http/fileserver.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct file_cache {
3333
explicitfile_cache(std::string doc_root) : doc_root_(std::move(doc_root)) {}
3434

3535
~file_cache()throw() {
36-
BOOST_FOREACH(region_map::value_typeconst &region, regions) {
36+
for (auto &region : regions) {
3737
munmap(region.second.first, region.second.second);
3838
}
3939
}
@@ -53,7 +53,11 @@ struct file_cache {
5353
int fd =open(real_filename.c_str(), O_RDONLY | O_NONBLOCK);
5454
#endif
5555
if (fd == -1)returnfalse;
56-
std::size_t size =lseek(fd,0, SEEK_END);
56+
off_t size =lseek(fd,0, SEEK_END);
57+
if (size == -1) {
58+
close(fd);
59+
returnfalse;
60+
}
5761
void *region =mmap(0, size, PROT_READ, MAP_PRIVATE, fd,0);
5862
if (region == MAP_FAILED) {
5963
close(fd);
@@ -68,6 +72,7 @@ struct file_cache {
6872
common_headers +3);
6973
headers[2].value =std::to_string(size);
7074
file_headers.insert(std::make_pair(real_filename, headers));
75+
close(fd);
7176
returntrue;
7277
}
7378

@@ -174,11 +179,16 @@ struct file_server {
174179
};
175180

176181
intmain(int,char *[]) {
177-
file_cachecache(".");
178-
file_serverhandler(cache);
179-
server::optionsoptions(handler);
180-
serverinstance(options.thread_pool(std::make_shared<utils::thread_pool>(4))
181-
.address("0.0.0.0")
182-
.port("8000"));
183-
instance.run();
182+
try {
183+
file_cachecache(".");
184+
file_serverhandler(cache);
185+
server::optionsoptions(handler);
186+
serverinstance(options.thread_pool(std::make_shared<utils::thread_pool>(4))
187+
.address("0.0.0.0")
188+
.port("8000"));
189+
instance.run();
190+
}
191+
catch (std::exception &e) {
192+
std::cerr << e.what() << std::endl;
193+
}
184194
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp