Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
2aaa2311
Unverified
Commit
2aaa2311
authored
Jan 12, 2020
by
Dennis Jenkins
Committed by
GitHub
Jan 12, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #659 from dennisjenkins75/master
Lots of misc cppcheck fixes
parents
f453c99b
14bafd53
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
68 additions
and
60 deletions
+68
-60
include/pistache/description.h
include/pistache/description.h
+14
-8
include/pistache/endpoint.h
include/pistache/endpoint.h
+4
-0
include/pistache/flags.h
include/pistache/flags.h
+2
-3
include/pistache/http.h
include/pistache/http.h
+7
-6
include/pistache/listener.h
include/pistache/listener.h
+1
-1
include/pistache/mailbox.h
include/pistache/mailbox.h
+6
-6
include/pistache/os.h
include/pistache/os.h
+1
-1
include/pistache/reactor.h
include/pistache/reactor.h
+5
-6
src/common/cookie.cc
src/common/cookie.cc
+5
-6
src/common/description.cc
src/common/description.cc
+14
-14
src/common/os.cc
src/common/os.cc
+5
-5
src/common/reactor.cc
src/common/reactor.cc
+3
-3
src/server/listener.cc
src/server/listener.cc
+1
-1
No files found.
include/pistache/description.h
View file @
2aaa2311
...
...
@@ -140,7 +140,7 @@ struct Info {
};
struct
InfoBuilder
{
InfoBuilder
(
Info
*
info
);
explicit
InfoBuilder
(
Info
*
info
);
InfoBuilder
&
termsOfService
(
std
::
string
value
);
InfoBuilder
&
contact
(
std
::
string
name
,
std
::
string
url
,
std
::
string
email
);
...
...
@@ -162,10 +162,16 @@ struct DataType {
template
<
typename
T
>
struct
DataTypeT
:
public
DataType
{
const
char
*
typeName
()
const
{
return
Traits
::
DataTypeInfo
<
T
>::
typeName
();
}
const
char
*
format
()
const
{
return
Traits
::
DataTypeInfo
<
T
>::
format
();
}
const
char
*
typeName
()
const
override
{
return
Traits
::
DataTypeInfo
<
T
>::
typeName
();
}
const
char
*
format
()
const
override
{
return
Traits
::
DataTypeInfo
<
T
>::
format
();
}
bool
validate
(
const
std
::
string
&
input
)
const
{
return
Traits
::
DataTypeValidation
<
T
>::
validate
(
input
);
}
bool
validate
(
const
std
::
string
&
input
)
const
override
{
return
Traits
::
DataTypeValidation
<
T
>::
validate
(
input
);
}
virtual
~
DataTypeT
()
{}
};
...
...
@@ -290,7 +296,7 @@ private:
};
struct
PathBuilder
{
PathBuilder
(
Path
*
path
);
explicit
PathBuilder
(
Path
*
path
);
template
<
typename
...
Mimes
>
PathBuilder
&
produces
(
Mimes
...
mimes
)
{
...
...
@@ -364,10 +370,10 @@ private:
struct
SubPath
{
SubPath
(
std
::
string
prefix
,
PathGroup
*
paths
);
PathBuilder
route
(
std
::
string
name
,
Http
::
Method
method
,
std
::
string
description
=
""
);
PathBuilder
route
(
const
std
::
string
&
name
,
Http
::
Method
method
,
std
::
string
description
=
""
);
PathBuilder
route
(
PathDecl
fragment
,
std
::
string
description
=
""
);
SubPath
path
(
std
::
string
prefix
);
SubPath
path
(
const
std
::
string
&
prefix
);
template
<
typename
T
>
void
parameter
(
std
::
string
name
,
std
::
string
description
)
{
...
...
@@ -447,7 +453,7 @@ private:
class
Swagger
{
public:
Swagger
(
const
Description
&
description
)
explicit
Swagger
(
const
Description
&
description
)
:
description_
(
description
)
,
uiPath_
()
,
uiDirectory_
()
...
...
include/pistache/endpoint.h
View file @
2aaa2311
...
...
@@ -21,6 +21,10 @@ public:
Options
&
threads
(
int
val
);
Options
&
threadsName
(
const
std
::
string
&
val
);
Options
&
flags
(
Flags
<
Tcp
::
Options
>
flags
);
Options
&
flags
(
Tcp
::
Options
tcp_opts
)
{
flags
(
Flags
<
Tcp
::
Options
>
(
tcp_opts
));
return
*
this
;
}
Options
&
backlog
(
int
val
);
Options
&
maxRequestSize
(
size_t
val
);
Options
&
maxResponseSize
(
size_t
val
);
...
...
include/pistache/flags.h
View file @
2aaa2311
...
...
@@ -58,8 +58,7 @@ public:
Flags
()
:
val
(
T
::
None
)
{
}
Flags
(
T
_val
)
:
val
(
_val
)
{
explicit
Flags
(
T
_val
)
:
val
(
_val
)
{
}
#define DEFINE_BITWISE_OP_CONST(Op) \
...
...
include/pistache/http.h
View file @
2aaa2311
...
...
@@ -213,7 +213,7 @@ public:
friend
class
ResponseWriter
;
Timeout
(
Timeout
&&
other
)
explicit
Timeout
(
Timeout
&&
other
)
:
handler
(
other
.
handler
)
,
request
(
std
::
move
(
other
.
request
))
,
transport
(
other
.
transport
)
...
...
@@ -221,6 +221,7 @@ public:
,
timerFd
(
other
.
timerFd
)
,
peer
(
std
::
move
(
other
.
peer
))
{
// cppcheck-suppress useInitializationList
other
.
timerFd
=
-
1
;
}
...
...
@@ -773,7 +774,7 @@ namespace Private {
feed
(
data
,
len
);
}
void
reset
()
{
void
reset
()
override
{
ParserBase
::
reset
();
request
.
headers_
.
clear
();
...
...
@@ -814,16 +815,16 @@ namespace Private {
class
Handler
:
public
Tcp
::
Handler
{
public:
void
onInput
(
const
char
*
buffer
,
size_t
len
,
const
std
::
shared_ptr
<
Tcp
::
Peer
>&
peer
);
void
onInput
(
const
char
*
buffer
,
size_t
len
,
const
std
::
shared_ptr
<
Tcp
::
Peer
>&
peer
)
override
;
void
onConnection
(
const
std
::
shared_ptr
<
Tcp
::
Peer
>&
peer
);
void
onDisconnection
(
const
std
::
shared_ptr
<
Tcp
::
Peer
>&
peer
);
void
onConnection
(
const
std
::
shared_ptr
<
Tcp
::
Peer
>&
peer
)
override
;
void
onDisconnection
(
const
std
::
shared_ptr
<
Tcp
::
Peer
>&
peer
)
override
;
virtual
void
onRequest
(
const
Request
&
request
,
ResponseWriter
response
)
=
0
;
virtual
void
onTimeout
(
const
Request
&
request
,
ResponseWriter
response
);
virtual
~
Handler
()
{
}
virtual
~
Handler
()
override
{
}
private:
Private
::
Parser
<
Http
::
Request
>&
getParser
(
const
std
::
shared_ptr
<
Tcp
::
Peer
>&
peer
)
const
;
...
...
include/pistache/listener.h
View file @
2aaa2311
...
...
@@ -51,7 +51,7 @@ public:
explicit
Listener
(
const
Address
&
address
);
void
init
(
size_t
workers
,
Flags
<
Options
>
options
=
Options
::
None
,
Flags
<
Options
>
options
=
Flags
<
Options
>
(
Options
::
None
)
,
const
std
::
string
&
workersName
=
""
,
int
backlog
=
Const
::
MaxBacklog
);
void
setHandler
(
const
std
::
shared_ptr
<
Handler
>&
handler
);
...
...
include/pistache/mailbox.h
View file @
2aaa2311
...
...
@@ -83,10 +83,10 @@ public:
}
event_fd
=
TRY_RET
(
eventfd
(
0
,
EFD_NONBLOCK
));
Tag
tag
(
event_fd
);
poller
.
addFd
(
event_fd
,
NotifyOn
::
Read
,
tag
);
Tag
tag
_
(
event_fd
);
poller
.
addFd
(
event_fd
,
Flags
<
Polling
::
NotifyOn
>
(
NotifyOn
::
Read
),
tag_
);
return
tag
;
return
tag
_
;
}
T
*
post
(
T
*
newData
)
{
...
...
@@ -270,10 +270,10 @@ public:
}
event_fd
=
TRY_RET
(
eventfd
(
0
,
EFD_NONBLOCK
));
Tag
tag
(
event_fd
);
poller
.
addFd
(
event_fd
,
NotifyOn
::
Read
,
tag
);
Tag
tag
_
(
event_fd
);
poller
.
addFd
(
event_fd
,
Flags
<
Polling
::
NotifyOn
>
(
NotifyOn
::
Read
),
tag_
);
return
tag
;
return
tag
_
;
}
template
<
class
U
>
...
...
include/pistache/os.h
View file @
2aaa2311
include/pistache/reactor.h
View file @
2aaa2311
...
...
@@ -28,7 +28,9 @@ namespace Aio {
// A set of fds that are ready
class
FdSet
{
public:
FdSet
(
std
::
vector
<
Polling
::
Event
>&&
events
)
FdSet
()
=
delete
;
explicit
FdSet
(
std
::
vector
<
Polling
::
Event
>&&
events
)
:
events_
()
{
events_
.
reserve
(
events
.
size
());
...
...
@@ -177,11 +179,8 @@ public:
class
AsyncContext
:
public
ExecutionContext
{
public:
explicit
AsyncContext
(
size_t
threads
,
const
std
::
string
&
threadsName
=
""
)
:
threads_
(
threads
)
{
threadsName_
=
threadsName
;
}
:
threads_
(
threads
),
threadsName_
(
threadsName
)
{
}
virtual
~
AsyncContext
()
{}
...
...
src/common/cookie.cc
View file @
2aaa2311
...
...
@@ -117,7 +117,7 @@ Cookie::fromRaw(const char* str, size_t len)
if
(
!
match_until
(
'='
,
cursor
))
throw
std
::
runtime_error
(
"Invalid cookie, missing value"
);
auto
name
=
nameToken
.
text
();
auto
name
_
=
nameToken
.
text
();
if
(
!
cursor
.
advance
(
1
))
throw
std
::
runtime_error
(
"Invalid cookie, missing value"
);
...
...
@@ -125,9 +125,9 @@ Cookie::fromRaw(const char* str, size_t len)
StreamCursor
::
Token
valueToken
(
cursor
);
match_until
(
';'
,
cursor
);
auto
value
=
valueToken
.
text
();
auto
value
_
=
valueToken
.
text
();
Cookie
cookie
(
std
::
move
(
name
),
std
::
move
(
value
));
Cookie
cookie
(
std
::
move
(
name
_
),
std
::
move
(
value_
));
if
(
cursor
.
eof
())
{
return
cookie
;
}
...
...
@@ -147,17 +147,16 @@ Cookie::fromRaw(const char* str, size_t len)
else
if
(
match_attribute
(
STR
(
"Expires"
),
cursor
,
&
cookie
,
&
Cookie
::
expires
))
;
// ext
else
{
StreamCursor
::
Token
nameToken
(
cursor
);
StreamCursor
::
Token
nameToken
_
(
cursor
);
match_until
(
'='
,
cursor
);
auto
name
=
nameToken
.
text
();
auto
name
=
nameToken
_
.
text
();
std
::
string
value
;
if
(
!
cursor
.
eof
())
{
auto
token
=
matchValue
(
cursor
);
value
=
token
.
text
();
}
cookie
.
ext
.
insert
(
std
::
make_pair
(
std
::
move
(
name
),
std
::
move
(
value
)));
}
}
while
(
!
cursor
.
eof
());
...
...
src/common/description.cc
View file @
2aaa2311
...
...
@@ -203,7 +203,7 @@ SubPath::SubPath(
{
}
PathBuilder
SubPath
::
route
(
std
::
string
name
,
Http
::
Method
method
,
std
::
string
description
)
{
SubPath
::
route
(
const
std
::
string
&
name
,
Http
::
Method
method
,
std
::
string
description
)
{
auto
fullPath
=
prefix
+
name
;
Path
path
(
std
::
move
(
fullPath
),
method
,
std
::
move
(
description
));
std
::
copy
(
std
::
begin
(
parameters
),
std
::
end
(
parameters
),
std
::
back_inserter
(
path
.
parameters
));
...
...
@@ -219,7 +219,7 @@ SubPath::route(PathDecl fragment, std::string description) {
}
SubPath
SubPath
::
path
(
std
::
string
prefix
)
{
SubPath
::
path
(
const
std
::
string
&
prefix
)
{
return
SubPath
(
this
->
prefix
+
prefix
,
paths
);
}
...
...
@@ -397,7 +397,7 @@ Swagger::install(Rest::Router& router) {
*/
struct
Path
{
Path
(
const
std
::
string
&
value
)
explicit
Path
(
const
std
::
string
&
value
)
:
value
(
value
)
,
trailingSlashValue
(
value
)
{
...
...
@@ -406,32 +406,32 @@ Swagger::install(Rest::Router& router) {
}
static
bool
hasTrailingSlash
(
const
Rest
::
Request
&
req
)
{
auto
res
=
req
.
resource
();
return
res
.
back
()
==
'/'
;
auto
res
_
=
req
.
resource
();
return
res
_
.
back
()
==
'/'
;
}
std
::
string
stripPrefix
(
const
Rest
::
Request
&
req
)
{
auto
res
=
req
.
resource
();
if
(
!
res
.
compare
(
0
,
value
.
size
(),
value
))
{
return
res
.
substr
(
value
.
size
());
auto
res
_
=
req
.
resource
();
if
(
!
res
_
.
compare
(
0
,
value
.
size
(),
value
))
{
return
res
_
.
substr
(
value
.
size
());
}
return
res
;
return
res
_
;
}
bool
matches
(
const
Rest
::
Request
&
req
)
const
{
auto
res
=
req
.
resource
();
if
(
value
==
res
)
auto
res
_
=
req
.
resource
();
if
(
value
==
res
_
)
return
true
;
if
(
res
==
trailingSlashValue
)
if
(
res
_
==
trailingSlashValue
)
return
true
;
return
false
;
}
bool
isPrefix
(
const
Rest
::
Request
&
req
)
{
auto
res
=
req
.
resource
();
return
!
res
.
compare
(
0
,
value
.
size
(),
value
);
auto
res
_
=
req
.
resource
();
return
!
res
_
.
compare
(
0
,
value
.
size
(),
value
);
}
const
std
::
string
&
withTrailingSlash
()
const
{
...
...
src/common/os.cc
View file @
2aaa2311
...
...
@@ -143,9 +143,9 @@ namespace Polling {
,
tag
(
_tag
)
{
}
Epoll
::
Epoll
()
{
epoll_fd
=
TRY_RET
(
epoll_create
(
Const
::
MaxEvents
));
}
Epoll
::
Epoll
()
:
epoll_fd
([
&
](){
return
TRY_RET
(
epoll_create
(
Const
::
MaxEvents
));}())
{
}
Epoll
::~
Epoll
()
{
...
...
@@ -261,7 +261,7 @@ NotifyFd::bind(Polling::Epoll& poller) {
event_fd
=
TRY_RET
(
eventfd
(
0
,
EFD_NONBLOCK
|
EFD_CLOEXEC
));
Polling
::
Tag
tag
(
event_fd
);
poller
.
addFd
(
event_fd
,
Polling
::
NotifyOn
::
Read
,
tag
,
Polling
::
Mode
::
Edge
);
poller
.
addFd
(
event_fd
,
Flags
<
Polling
::
NotifyOn
>
(
Polling
::
NotifyOn
::
Read
)
,
tag
,
Polling
::
Mode
::
Edge
);
return
tag
;
}
...
...
src/common/reactor.cc
View file @
2aaa2311
...
...
@@ -109,7 +109,7 @@ public:
Polling
::
Mode
mode
=
Polling
::
Mode
::
Level
)
override
{
auto
pollTag
=
encodeTag
(
key
,
tag
);
poller
.
addFd
(
fd
,
interest
,
pollTag
,
mode
);
poller
.
addFd
(
fd
,
Flags
<
Polling
::
NotifyOn
>
(
interest
)
,
pollTag
,
mode
);
}
void
registerFdOneShot
(
...
...
@@ -120,7 +120,7 @@ public:
Polling
::
Mode
mode
=
Polling
::
Mode
::
Level
)
override
{
auto
pollTag
=
encodeTag
(
key
,
tag
);
poller
.
addFdOneShot
(
fd
,
interest
,
pollTag
,
mode
);
poller
.
addFdOneShot
(
fd
,
Flags
<
Polling
::
NotifyOn
>
(
interest
)
,
pollTag
,
mode
);
}
void
modifyFd
(
...
...
@@ -131,7 +131,7 @@ public:
Polling
::
Mode
mode
=
Polling
::
Mode
::
Level
)
override
{
auto
pollTag
=
encodeTag
(
key
,
tag
);
poller
.
rearmFd
(
fd
,
interest
,
pollTag
,
mode
);
poller
.
rearmFd
(
fd
,
Flags
<
Polling
::
NotifyOn
>
(
interest
)
,
pollTag
,
mode
);
}
void
runOnce
()
override
{
...
...
src/server/listener.cc
View file @
2aaa2311
...
...
@@ -205,7 +205,7 @@ Listener::bind(const Address& address) {
}
make_non_blocking
(
fd
);
poller
.
addFd
(
fd
,
Polling
::
NotifyOn
::
Read
,
Polling
::
Tag
(
fd
));
poller
.
addFd
(
fd
,
Flags
<
Polling
::
NotifyOn
>
(
Polling
::
NotifyOn
::
Read
)
,
Polling
::
Tag
(
fd
));
listen_fd
=
fd
;
auto
transport
=
std
::
make_shared
<
Transport
>
(
handler_
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment