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
d392cd57
Commit
d392cd57
authored
Apr 03, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
64fddd20
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
wcfs/client/wcfs_misc.cpp
wcfs/client/wcfs_misc.cpp
+11
-11
No files found.
wcfs/client/wcfs_misc.cpp
View file @
d392cd57
...
...
@@ -43,7 +43,7 @@ namespace os {
global
<
error
>
ErrClosed
=
errors
::
New
(
"file already closed"
);
//
XXX -> make public
//
TODO -> os.PathError + err=syscall.Errno
static
error
_pathError
(
const
char
*
op
,
const
string
&
path
,
int
syserr
);
int
_File
::
fd
()
const
{
return
_fd
;
}
...
...
@@ -60,7 +60,7 @@ void _File::decref() {
tuple
<
File
,
error
>
open
(
const
string
&
path
,
int
flags
,
mode_t
mode
)
{
int
fd
=
::
open
(
path
.
c_str
(),
flags
,
mode
);
if
(
fd
==
-
1
)
return
make_tuple
(
nil
,
_pathError
(
"open"
,
path
,
errno
));
// XXX -> wrapper?
return
make_tuple
(
nil
,
_pathError
(
"open"
,
path
,
errno
));
File
f
=
adoptref
(
new
_File
);
f
->
_path
=
path
;
...
...
@@ -131,7 +131,7 @@ static error _pathError(const char *op, const string &path, int syserr) {
char
ebuf
[
128
];
char
*
estr
=
strerror_r
(
syserr
,
ebuf
,
sizeof
(
ebuf
));
return
fmt
::
errorf
(
"%s %s: %s"
,
op
,
v
(
path
),
estr
);
//
XXX estr -> errnoError
return
fmt
::
errorf
(
"%s %s: %s"
,
op
,
v
(
path
),
estr
);
//
TODO estr -> syscall.Errno
}
}
// os::
...
...
@@ -174,7 +174,7 @@ error map_into(void *addr, size_t size, int prot, int flags, os::File f, off_t o
error
unmap
(
void
*
addr
,
size_t
size
)
{
int
err
=
::
munmap
(
addr
,
size
);
if
(
err
!=
0
)
return
os
::
_pathError
(
"munmap"
,
"<memory>"
/*XXX ok?*/
,
errno
);
return
os
::
_pathError
(
"munmap"
,
"<memory>"
,
errno
);
return
nil
;
}
...
...
@@ -228,18 +228,18 @@ tuple<uint64_t, error> parseHex64(const string& s) {
return
make_tuple
(
0
,
fmt
::
errorf
(
"hex64 %s invalid"
,
v
(
s
)));
uint64_t
v
;
int
n
=
sscanf
(
s
.
c_str
(),
"%16"
SCNx64
,
&
v
);
// XXX verify
int
n
=
sscanf
(
s
.
c_str
(),
"%16"
SCNx64
,
&
v
);
if
(
n
!=
1
)
return
make_tuple
(
0
,
fmt
::
errorf
(
"hex64 %s invalid"
,
v
(
s
)));
return
make_tuple
(
v
,
nil
);
}
// pa
e
seInt decodes string s as signed decimal integer.
// pa
r
seInt 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
int
n
=
sscanf
(
s
.
c_str
(),
"%"
SCNi64
,
&
v
);
if
(
!
(
n
==
1
&&
std
::
to_string
(
v
)
==
s
))
return
make_tuple
(
0
,
fmt
::
errorf
(
"int %s invalid"
,
v
(
s
)));
return
make_tuple
(
v
,
nil
);
}
...
...
@@ -247,8 +247,8 @@ tuple<int64_t, error> parseInt(const string& s) {
// parseUint decodes string s as unsigned decimal integer.
tuple
<
uint64_t
,
error
>
parseUint
(
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
int
n
=
sscanf
(
s
.
c_str
(),
"%"
SCNu64
,
&
v
);
if
(
!
(
n
==
1
&&
std
::
to_string
(
v
)
==
s
))
return
make_tuple
(
0
,
fmt
::
errorf
(
"uint %s invalid"
,
v
(
s
)));
return
make_tuple
(
v
,
nil
);
}
...
...
@@ -310,7 +310,7 @@ void __Logf(const char *file, int line, char level, const char *format, ...) {
pid_t
tid
=
syscall
(
SYS_gettid
);
string
prefix
=
fmt
::
sprintf
(
"%c%s.%06d % 7d %s:%d] "
,
level
,
t_buf
,
t_us
,
tid
,
file
,
line
);
//
XXX
better to emit prefix and msg in one go.
//
TODO
better to emit prefix and msg in one go.
flockfile
(
stderr
);
fprintf
(
stderr
,
"%s"
,
v
(
prefix
));
...
...
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