Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
9052d96a
Commit
9052d96a
authored
Oct 30, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d20e0353
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+17
-0
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+1
-0
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+3
-3
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
9052d96a
...
@@ -242,5 +242,22 @@ tuple<uint64_t, error> parseHex64(const string& s) {
...
@@ -242,5 +242,22 @@ tuple<uint64_t, error> parseHex64(const string& s) {
return
make_tuple
(
v
,
nil
);
return
make_tuple
(
v
,
nil
);
}
}
// paeseInt decodes string s as signed decimal integer.
tuple
<
int64_t
,
error
>
parseInt
(
const
string
&
s
)
{
int64_t
v
;
int
n
=
sscanf
(
s
.
c_str
(),
"%"
SCNi64
,
&
v
);
// XXX verify
if
(
!
(
n
==
1
&&
std
::
to_string
(
v
)
==
s
))
// XXX verify
return
make_tuple
(
0
,
fmt
::
errorf
(
"int %s invalid"
,
s
.
c_str
()));
return
make_tuple
(
v
,
nil
);
}
// parseUint decodes string s as unsigned decimal integer.
tuple
<
uint64_t
,
error
>
parse_uint
(
const
string
&
s
)
{
uint64_t
v
;
int
n
=
sscanf
(
s
.
c_str
(),
"%"
SCNu64
,
&
v
);
// XXX verify
if
(
!
(
n
==
1
&&
std
::
to_string
(
v
)
==
s
))
// XXX verify
return
make_tuple
(
0
,
fmt
::
errorf
(
"uint %s invalid"
,
s
.
c_str
()));
return
make_tuple
(
v
,
nil
);
}
}
// xstrconv::
}
// xstrconv::
wcfs/internal/wcfs_misc.h
View file @
9052d96a
...
@@ -201,6 +201,7 @@ namespace xstrconv {
...
@@ -201,6 +201,7 @@ namespace xstrconv {
tuple
<
uint64_t
,
error
>
parseHex64
(
const
string
&
s
);
tuple
<
uint64_t
,
error
>
parseHex64
(
const
string
&
s
);
tuple
<
int64_t
,
error
>
parseInt
(
const
string
&
s
);
tuple
<
int64_t
,
error
>
parseInt
(
const
string
&
s
);
tuple
<
uint64_t
,
error
>
parseUint
(
const
string
&
s
);
}
// xstrconv
}
// xstrconv
...
...
wcfs/internal/wcfs_virtmem.cpp
View file @
9052d96a
...
@@ -42,7 +42,6 @@ using namespace golang;
...
@@ -42,7 +42,6 @@ using namespace golang;
#include <sys/stat.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
#include <stdint.h>
#include <stdint.h>
#include <inttypes.h>
#include "wcfs_misc.h"
#include "wcfs_misc.h"
...
@@ -767,8 +766,9 @@ error rxPkt::from_string(const string &rx) {
...
@@ -767,8 +766,9 @@ error rxPkt::from_string(const string &rx) {
string
sid
=
rx
.
substr
(
0
,
sp
);
string
sid
=
rx
.
substr
(
0
,
sp
);
string
smsg
=
rx
.
substr
(
sp
+
1
);
string
smsg
=
rx
.
substr
(
sp
+
1
);
sscanf
(
sid
.
c_str
(),
"%"
SCNu64
,
&
pkt
.
stream
);
error
err
;
if
(
std
::
to_string
(
pkt
.
stream
)
!=
sid
)
tie
(
pkt
.
stream
,
err
)
=
xstrconv
::
parseUint
(
sid
);
if
(
err
!=
nil
)
return
fmt
::
errorf
(
"invalid pkt: invalid stream ID"
);
return
fmt
::
errorf
(
"invalid pkt: invalid stream ID"
);
auto
msglen
=
smsg
.
length
();
auto
msglen
=
smsg
.
length
();
...
...
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