Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64a63acb authored by Josh Gao's avatar Josh Gao
Browse files

adb: partially clang-format sysdeps_win32.cpp.

clang-format some functions that I'm about to touch, but do it in a
separate commit to avoid making the actual changes unreadable.

Test: treehugger
Change-Id: I7dc5258d9ecc1c091d42311149d9e18ae483715b
parent 116aa0a4
Loading
Loading
Loading
Loading
+53 −63
Original line number Diff line number Diff line
@@ -355,8 +355,7 @@ static int _fh_file_lseek(FH f, int pos, int origin) {
/**************************************************************************/
/**************************************************************************/

int  adb_open(const char*  path, int  options)
{
int adb_open(const char* path, int options) {
    FH f;

    DWORD desiredAccess = 0;
@@ -387,8 +386,8 @@ int adb_open(const char* path, int options)
    if (!android::base::UTF8ToWide(path, &path_wide)) {
        return -1;
    }
    f->fh_handle = CreateFileW( path_wide.c_str(), desiredAccess, shareMode,
                                NULL, OPEN_EXISTING, 0, NULL );
    f->fh_handle =
        CreateFileW(path_wide.c_str(), desiredAccess, shareMode, NULL, OPEN_EXISTING, 0, NULL);

    if (f->fh_handle == INVALID_HANDLE_VALUE) {
        const DWORD err = GetLastError();
@@ -418,8 +417,7 @@ int adb_open(const char* path, int options)
}

/* ignore mode on Win32 */
int  adb_creat(const char*  path, int  mode)
{
int adb_creat(const char* path, int mode) {
    FH f;

    f = _fh_alloc(&_fh_file_class);
@@ -431,10 +429,8 @@ int adb_creat(const char* path, int mode)
    if (!android::base::UTF8ToWide(path, &path_wide)) {
        return -1;
    }
    f->fh_handle = CreateFileW( path_wide.c_str(), GENERIC_WRITE,
                                FILE_SHARE_READ | FILE_SHARE_WRITE,
                                NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
                                NULL );
    f->fh_handle = CreateFileW(path_wide.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
                               NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

    if (f->fh_handle == INVALID_HANDLE_VALUE) {
        const DWORD err = GetLastError();
@@ -493,8 +489,7 @@ ssize_t adb_writev(int fd, const adb_iovec* iov, int iovcnt) {
    return f->clazz->_fh_writev(f, iov, iovcnt);
}

int  adb_lseek(int  fd, int  pos, int  where)
{
int adb_lseek(int fd, int pos, int where) {
    FH f = _fh_from_int(fd, __func__);

    if (!f) {
@@ -504,9 +499,7 @@ int adb_lseek(int fd, int pos, int where)
    return f->clazz->_fh_lseek(f, pos, where);
}


int  adb_close(int  fd)
{
int adb_close(int fd) {
    FH f = _fh_from_int(fd, __func__);

    if (!f) {
@@ -994,8 +987,7 @@ int adb_register_socket(SOCKET s) {
}

#undef accept
int  adb_socket_accept(int  serverfd, struct sockaddr*  addr, socklen_t  *addrlen)
{
int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t* addrlen) {
    FH serverfh = _fh_from_int(serverfd, __func__);

    if (!serverfh || serverfh->clazz != &_fh_socket_class) {
@@ -1014,8 +1006,8 @@ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrle
    fh->fh_socket = accept(serverfh->fh_socket, addr, addrlen);
    if (fh->fh_socket == INVALID_SOCKET) {
        const DWORD err = WSAGetLastError();
        LOG(ERROR) << "adb_socket_accept: accept on fd " << serverfd <<
                      " failed: " + android::base::SystemErrorCodeToString(err);
        LOG(ERROR) << "adb_socket_accept: accept on fd " << serverfd
                   << " failed: " + android::base::SystemErrorCodeToString(err);
        _socket_set_errno(err);
        return -1;
    }
@@ -1027,9 +1019,7 @@ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrle
    return fd;
}


int  adb_setsockopt( int  fd, int  level, int  optname, const void*  optval, socklen_t  optlen )
{
int adb_setsockopt(int fd, int level, int optname, const void* optval, socklen_t optlen) {
    FH fh = _fh_from_int(fd, __func__);

    if (!fh || fh->clazz != &_fh_socket_class) {
@@ -1042,12 +1032,12 @@ int adb_setsockopt( int fd, int level, int optname, const void* optval, soc
    // to set SOL_SOCKET, SO_SNDBUF/SO_RCVBUF, ignore it since the OS has
    // auto-tuning.

    int result = setsockopt( fh->fh_socket, level, optname,
                             reinterpret_cast<const char*>(optval), optlen );
    int result =
        setsockopt(fh->fh_socket, level, optname, reinterpret_cast<const char*>(optval), optlen);
    if (result == SOCKET_ERROR) {
        const DWORD err = WSAGetLastError();
        D("adb_setsockopt: setsockopt on fd %d level %d optname %d failed: %s\n",
          fd, level, optname, android::base::SystemErrorCodeToString(err).c_str());
        D("adb_setsockopt: setsockopt on fd %d level %d optname %d failed: %s\n", fd, level,
          optname, android::base::SystemErrorCodeToString(err).c_str());
        _socket_set_errno(err);
        result = -1;
    }