Skip to content

Commit

Permalink
Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolf3s committed Jan 1, 2024
1 parent 2cbae8a commit fd85cf3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void AES128_ECB_decrypt(uint8_t* input, const uint8_t* key, uint8_t *output)
{
// The array that stores the round keys.
uint8_t roundKey[176];

// Copy input to output, and work in-memory on output
BlockCopy(output, input);

Expand Down
16 changes: 7 additions & 9 deletions lib/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ int nterror_to_errno(uint32_t status) {
return EAGAIN;
case SMB2_STATUS_ABORTED:
return ECONNRESET;
case SMB2_STATUS_NO_SUCH_FILE:
case SMB2_STATUS_NO_SUCH_FILE:
case SMB2_STATUS_NO_SUCH_DEVICE:
case SMB2_STATUS_BAD_NETWORK_NAME:
case SMB2_STATUS_OBJECT_NAME_NOT_FOUND:
Expand Down Expand Up @@ -1107,24 +1107,22 @@ int nterror_to_errno(uint32_t status) {
case SMB2_STATUS_CANNOT_DELETE:
case SMB2_STATUS_FILE_DELETED:
return EPERM;
case SMB2_STATUS_NO_MORE_FILES:
case SMB2_STATUS_NO_MORE_FILES:
return ENODATA;
case SMB2_STATUS_LOGON_FAILURE:
return ECONNREFUSED;
case SMB2_STATUS_NOT_A_DIRECTORY:
case SMB2_STATUS_NOT_A_DIRECTORY:
return ENOTDIR;
case SMB2_STATUS_NOT_IMPLEMENTED:
case SMB2_STATUS_INVALID_DEVICE_REQUEST:

case SMB2_STATUS_ILLEGAL_FUNCTION:

case SMB2_STATUS_INVALID_PARAMETER:
case SMB2_STATUS_INVALID_PARAMETER:
case SMB2_STATUS_NOT_SUPPORTED:
case SMB2_STATUS_NOT_A_REPARSE_POINT:
return EINVAL;
case SMB2_STATUS_STOPPED_ON_SYMLINK:
return ENOLINK;
case SMB2_STATUS_TOO_MANY_OPENED_FILES:
case SMB2_STATUS_TOO_MANY_OPENED_FILES:
return EMFILE;
case SMB2_STATUS_SECTION_TOO_BIG:
case SMB2_STATUS_TOO_MANY_PAGING_FILES:
Expand All @@ -1134,7 +1132,7 @@ int nterror_to_errno(uint32_t status) {
return EXDEV;
case SMB2_STATUS_SHARING_VIOLATION:
return ETXTBSY;
case SMB2_STATUS_FILE_LOCK_CONFLICT:
case SMB2_STATUS_FILE_LOCK_CONFLICT:
case SMB2_STATUS_LOCK_NOT_GRANTED:
return EDEADLK;
case SMB2_STATUS_OBJECT_NAME_COLLISION:
Expand Down Expand Up @@ -1175,7 +1173,7 @@ int nterror_to_errno(uint32_t status) {
return ENOEXEC;
case SMB2_STATUS_IO_TIMEOUT:
return ETIMEDOUT;
case SMB2_STATUS_INSUFFICIENT_RESOURCES:
case SMB2_STATUS_INSUFFICIENT_RESOURCES:
return EBUSY;
case SMB2_STATUS_INTERNAL_ERROR:
/* Fall through. */
Expand Down
2 changes: 1 addition & 1 deletion lib/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ struct smb2_context *smb2_init_context(void)
#else
srandom(time(NULL) ^ getpid() ^ ctr++);
#endif
smb2 = calloc(1, sizeof(struct smb2_context));
smb2 = calloc(1, sizeof(struct smb2_context));
if (smb2 == NULL) {
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/libsmb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ smb2_close_context(struct smb2_context *smb2)
if (smb2->change_fd) {
smb2->change_fd(smb2, smb2->fd, SMB2_DEL_FD);
}
close(smb2->fd);
close(smb2->fd);
smb2->fd = -1;
}

Expand Down Expand Up @@ -2541,7 +2541,7 @@ disconnect_cb_2(struct smb2_context *smb2, int status,
if (smb2->change_fd) {
smb2->change_fd(smb2, smb2->fd, SMB2_DEL_FD);
}
close(smb2->fd);
close(smb2->fd);
smb2->fd = -1;
}

Expand Down
32 changes: 15 additions & 17 deletions lib/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@
#include "smb3-seal.h"
#include "libsmb2-private.h"



#define MAX_URL_SIZE 1024

/* Timeout in ms between 2 consecutive socket connection.
Expand Down Expand Up @@ -270,8 +268,8 @@ smb2_write_to_socket(struct smb2_context *smb2)

count = writev(smb2->fd, tmpiov, niov);
if (count == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
return 0;
if (errno == EAGAIN || errno == EWOULDBLOCK) {
return 0;
}
smb2_set_error(smb2, "Error when writing to "
"socket :%d %s", errno,
Expand Down Expand Up @@ -861,7 +859,7 @@ set_tcp_sockopt(t_socket sockfd, int optname, int value)
#if !defined(SOL_TCP)
struct protoent *buf;
if ((buf = getprotobyname("tcp")) != NULL) {
level = buf->p_proto;
level = buf->p_proto;
} else {
return -1;
}
Expand All @@ -884,7 +882,7 @@ connect_async_ai(struct smb2_context *smb2, const struct addrinfo *ai, int *fd_o
struct LingerStruct const lin = { 1, 0 }; /* if l_linger is zero, sends RST after FIN */
#endif
#ifdef _XBOX
BOOL bBroadcast = TRUE;
BOOL bBroadcast = TRUE;
#endif
memset(&ss, 0, sizeof(ss));
switch (ai->ai_family) {
Expand Down Expand Up @@ -923,18 +921,18 @@ connect_async_ai(struct smb2_context *smb2, const struct addrinfo *ai, int *fd_o
}

#ifdef _XBOX
if(setsockopt(fd, SOL_SOCKET, 0x5801, (PCSTR)&bBroadcast, sizeof(BOOL) ) != 0 )
{
if(setsockopt(fd, SOL_SOCKET, 0x5801, (PCSTR)&bBroadcast, sizeof(BOOL) ) != 0 )
{
#if 0
return 0;
return 0;
#endif
}
if(setsockopt(fd, SOL_SOCKET, 0x5802, (PCSTR)&bBroadcast, sizeof(BOOL)) != 0)
{
}
if(setsockopt(fd, SOL_SOCKET, 0x5802, (PCSTR)&bBroadcast, sizeof(BOOL)) != 0)
{
#if 0
return 0;
return 0;
#endif
}
}
#endif

set_nonblocking(fd);
Expand All @@ -952,7 +950,7 @@ connect_async_ai(struct smb2_context *smb2, const struct addrinfo *ai, int *fd_o
#endif
smb2_set_error(smb2, "Connect failed with errno : "
"%s(%d)", strerror(errno), errno);
close(fd);
close(fd);
return -EIO;
}

Expand Down Expand Up @@ -1081,9 +1079,9 @@ smb2_connect_async(struct smb2_context *smb2, const char *server,
#if defined(_WINDOWS) || defined(_XBOX)
if (err == WSANOTINITIALISED)
{
smb2_set_error(smb2, "Winsock was not initialized. "
smb2_set_error(smb2, "Winsock was not initialized. "
"Please call WSAStartup().");
return -WSANOTINITIALISED;
return -WSANOTINITIALISED;
}
else
#endif
Expand Down

0 comments on commit fd85cf3

Please sign in to comment.