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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
d20e0353
Commit
d20e0353
authored
Oct 30, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d1c36492
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
3 deletions
+33
-3
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+22
-0
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+8
-0
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+3
-3
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
d20e0353
...
...
@@ -24,7 +24,9 @@
#include <golang/libgolang.h>
using
namespace
golang
;
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
...
...
@@ -222,3 +224,23 @@ vector<string> split(const string &s, char sep) {
}
}
// strings::
// xstrconv:: (strconv-like)
namespace
xstrconv
{
// parseHex64 decodes 16-character-wide hex-encoded string into uint64.
tuple
<
uint64_t
,
error
>
parseHex64
(
const
string
&
s
)
{
if
(
s
.
size
()
!=
16
)
return
make_tuple
(
0
,
fmt
::
errorf
(
"hex64 %s invalid"
,
s
.
c_str
()));
uint64_t
v
;
int
n
=
sscanf
(
s
.
c_str
(),
"%16"
SCNx64
,
&
v
);
// XXX verify
if
(
n
!=
1
)
return
make_tuple
(
0
,
fmt
::
errorf
(
"hex64 %s invalid"
,
s
.
c_str
()));
return
make_tuple
(
v
,
nil
);
}
}
// xstrconv::
wcfs/internal/wcfs_misc.h
View file @
d20e0353
...
...
@@ -196,4 +196,12 @@ struct set : std::unordered_set<Key> {
};
// xstrconv::
namespace
xstrconv
{
tuple
<
uint64_t
,
error
>
parseHex64
(
const
string
&
s
);
tuple
<
int64_t
,
error
>
parseInt
(
const
string
&
s
);
}
// xstrconv
#endif
wcfs/internal/wcfs_virtmem.cpp
View file @
d20e0353
...
...
@@ -701,13 +701,13 @@ static error _parsePinReq(PinReq *pin, const rxPkt *pkt) {
return
fmt
::
errorf
(
"expected 3 arguments, got %zd"
,
argv
.
size
());
error
err
;
tie
(
pin
->
foid
,
err
)
=
_
parseHex64
(
argv
[
0
]);
tie
(
pin
->
foid
,
err
)
=
xstrconv
::
parseHex64
(
argv
[
0
]);
if
(
err
!=
nil
)
return
fmt
::
errorf
(
"invalid foid"
);
if
(
!
strings
::
has_prefix
(
argv
[
1
],
'#'
))
return
fmt
::
errorf
(
"invalid blk"
);
tie
(
pin
->
blk
,
err
)
=
_
parseInt
(
argv
[
1
].
substr
(
1
));
tie
(
pin
->
blk
,
err
)
=
xstrconv
::
parseInt
(
argv
[
1
].
substr
(
1
));
if
(
err
!=
nil
)
return
fmt
::
errorf
(
"invalid blk"
);
...
...
@@ -717,7 +717,7 @@ static error _parsePinReq(PinReq *pin, const rxPkt *pkt) {
if
(
at
==
"head"
)
{
pin
->
at
=
TidHead
;
}
else
{
tie
(
pin
->
at
,
err
)
=
_
parseHex64
(
at
);
tie
(
pin
->
at
,
err
)
=
xstrconv
::
parseHex64
(
at
);
if
(
err
!=
nil
)
return
fmt
::
errorf
(
"invalid at"
);
}
...
...
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