Commit d392cd57 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 64fddd20
......@@ -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);
}
// paeseInt decodes string s as signed decimal integer.
// parseInt 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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment