Skip to content

Commit

Permalink
Replace int to t_socket for file descriptor
Browse files Browse the repository at this point in the history
Supress unused variable warning
  • Loading branch information
Wolf3s committed Nov 20, 2023
1 parent cd0d6cf commit 4b1ef1f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion include/libsmb2-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ void smb2_free_all_fhs(struct smb2_context *smb2);
void smb2_free_all_dirs(struct smb2_context *smb2);

int smb2_read_from_buf(struct smb2_context *smb2);
void smb2_change_events(struct smb2_context *smb2, int fd, int events);
void smb2_change_events(struct smb2_context *smb2, t_socket fd, int events);
void smb2_timeout_pdus(struct smb2_context *smb2);

struct dcerpc_context;
Expand Down
8 changes: 4 additions & 4 deletions include/smb2/libsmb2.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ smb2_get_fds(struct smb2_context *smb2, size_t *fd_count, int *timeout);
*/
#define SMB2_ADD_FD 0
#define SMB2_DEL_FD 1
typedef void (*smb2_change_fd_cb)(struct smb2_context *smb2, int fd, int cmd);
typedef void (*smb2_change_events_cb)(struct smb2_context *smb2, int fd,
typedef void (*smb2_change_fd_cb)(struct smb2_context *smb2, t_socket fd, int cmd);
typedef void (*smb2_change_events_cb)(struct smb2_context *smb2, t_socket fd,
int events);
void smb2_fd_event_callbacks(struct smb2_context *smb2,
smb2_change_fd_cb change_fd,
Expand All @@ -176,7 +176,7 @@ void smb2_fd_event_callbacks(struct smb2_context *smb2,
* used and must be freed by calling smb2_destroy_context().
*
*/
int smb2_service(struct smb2_context *smb2, int revents);
t_socket smb2_service(struct smb2_context *smb2, int revents);

/*
* Called to process the events when events become available for the smb2
Expand All @@ -193,7 +193,7 @@ int smb2_service(struct smb2_context *smb2, int revents);
* used and must be freed by calling smb2_destroy_context().
*
*/
int smb2_service_fd(struct smb2_context *smb2, int fd, int revents);
t_socket smb2_service_fd(struct smb2_context *smb2, t_socket fd, int revents);

/*
* Set the timeout in seconds after which a command will be aborted with
Expand Down
10 changes: 5 additions & 5 deletions lib/dcerpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ dce_unfragment_ioctl(struct dcerpc_context *dce, struct smb2_iovec *iov)
int offset = 0;
int unfragment_len;
struct dcerpc_header hdr, next_hdr;
struct smb2_iovec tmpiov;
struct smb2_iovec tmpiov _U_;

dcerpc_decode_header(iov, &hdr);
if (hdr.rpc_vers != 5 || hdr.rpc_vers_minor != 0 ||
Expand Down Expand Up @@ -1422,7 +1422,7 @@ dcerpc_call_cb(struct smb2_context *smb2, int status,
{
struct dcerpc_pdu *pdu = private_data;
struct dcerpc_context *dce = pdu->dce;
struct smb2_iovec iov;
struct smb2_iovec iov _U_;
struct smb2_ioctl_reply *rep = command_data;
void *payload;
int ret;
Expand Down Expand Up @@ -1478,7 +1478,7 @@ dcerpc_call_async(struct dcerpc_context *dce,
struct dcerpc_pdu *pdu;
struct smb2_pdu *smb2_pdu;
struct smb2_ioctl_request req;
struct smb2_iovec iov;
struct smb2_iovec iov _U_;
int offset;

pdu = dcerpc_allocate_pdu(dce, DCERPC_ENCODE, NSE_BUF_SIZE);
Expand Down Expand Up @@ -1560,7 +1560,7 @@ smb2_bind_cb(struct smb2_context *smb2, int status,
{
struct dcerpc_pdu *pdu = private_data;
struct dcerpc_context *dce = pdu->dce;
struct smb2_iovec iov;
struct smb2_iovec iov _U_;
struct smb2_ioctl_reply *rep = command_data;
int i;

Expand Down Expand Up @@ -1627,7 +1627,7 @@ dcerpc_bind_async(struct dcerpc_context *dce, dcerpc_cb cb,
struct dcerpc_pdu *pdu;
struct smb2_pdu *smb2_pdu;
struct smb2_ioctl_request req;
struct smb2_iovec iov;
struct smb2_iovec iov _U_;
int offset;

pdu = dcerpc_allocate_pdu(dce, DCERPC_ENCODE, NSE_BUF_SIZE);
Expand Down
2 changes: 1 addition & 1 deletion lib/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void smb2_destroy_url(struct smb2_url *url)
struct smb2_context *smb2_init_context(void)
{
struct smb2_context *smb2;
char buf[1024];
char buf[1024] _U_;
int i, ret;
static int ctr;

Expand Down
10 changes: 5 additions & 5 deletions lib/libsmb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ decode_dirents(struct smb2_context *smb2, struct smb2dir *dir,
uint32_t offset = 0;

do {
struct smb2_iovec tmp_vec;
struct smb2_iovec tmp_vec _U_;

/* Make sure we do not go beyond end of vector */
if (offset >= vec->len) {
Expand Down Expand Up @@ -368,7 +368,7 @@ query_cb(struct smb2_context *smb2, int status,
struct smb2_query_directory_reply *rep = command_data;

if (status == SMB2_STATUS_SUCCESS) {
struct smb2_iovec vec;
struct smb2_iovec vec _U_;
struct smb2_query_directory_request req;
struct smb2_pdu *pdu;

Expand Down Expand Up @@ -754,7 +754,7 @@ session_setup_cb(struct smb2_context *smb2, int status,
}

if (smb2->hdr.flags & SMB2_FLAGS_SIGNED) {
uint8_t signature[16];
uint8_t signature[16] _U_;

memcpy(&signature[0], &smb2->in.iov[1].buf[48], 16);
if (smb2_calc_signature(smb2, &smb2->in.iov[1].buf[48],
Expand Down Expand Up @@ -2097,7 +2097,7 @@ smb2_truncate_async(struct smb2_context *smb2, const char *path,
struct smb2_set_info_request si_req;
struct smb2_close_request cl_req;
struct smb2_pdu *pdu, *next_pdu;
struct smb2_file_end_of_file_info eofi;
struct smb2_file_end_of_file_info eofi _U_;

if (smb2 == NULL) {
return -EINVAL;
Expand Down Expand Up @@ -2230,7 +2230,7 @@ smb2_rename_async(struct smb2_context *smb2, const char *oldpath,
struct smb2_set_info_request si_req;
struct smb2_close_request cl_req;
struct smb2_pdu *pdu, *next_pdu;
struct smb2_file_rename_info rn_info;
struct smb2_file_rename_info rn_info _U_;
uint8_t *ptr;

if (smb2 == NULL) {
Expand Down
18 changes: 9 additions & 9 deletions lib/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ smb2_close_connecting_fds(struct smb2_context *smb2)
{
size_t i;
for (i = 0; i < smb2->connecting_fds_count; ++i) {
int fd = smb2->connecting_fds[i];
t_socket fd = smb2->connecting_fds[i];

/* Don't close the connected fd */
if (fd == smb2->fd || fd == -1)
Expand Down Expand Up @@ -188,7 +188,7 @@ smb2_write_to_socket(struct smb2_context *smb2)
}

while ((pdu = smb2->outqueue) != NULL) {
struct iovec iov[SMB2_MAX_VECTORS];
struct iovec iov[SMB2_MAX_VECTORS] _U_;
struct iovec *tmpiov;
struct smb2_pdu *tmp_pdu;
size_t num_done = pdu->out.num_done;
Expand Down Expand Up @@ -284,7 +284,7 @@ typedef ssize_t (*read_func)(struct smb2_context *smb2,
static int smb2_read_data(struct smb2_context *smb2, read_func func,
int has_xfrmhdr)
{
struct iovec iov[SMB2_MAX_VECTORS];
struct iovec iov[SMB2_MAX_VECTORS] _U_;
struct iovec *tmpiov;
int i, niov, is_chained;
size_t num_done;
Expand Down Expand Up @@ -565,7 +565,7 @@ static int smb2_read_data(struct smb2_context *smb2, read_func func,
if (smb2->sign &&
(smb2->hdr.flags & SMB2_FLAGS_SIGNED) &&
(smb2->hdr.command != SMB2_SESSION_SETUP) ) {
uint8_t signature[16];
uint8_t signature[16] _U_;
memcpy(&signature[0], &smb2->in.iov[1 + iov_offset].buf[48], 16);
if (smb2_calc_signature(smb2, &smb2->in.iov[1 + iov_offset].buf[48],
&smb2->in.iov[1 + iov_offset],
Expand Down Expand Up @@ -652,7 +652,7 @@ smb2_read_from_buf(struct smb2_context *smb2)
}

static void
smb2_close_connecting_fd(struct smb2_context *smb2, int fd)
smb2_close_connecting_fd(struct smb2_context *smb2, t_socket fd)
{
size_t i;

Expand All @@ -669,8 +669,8 @@ smb2_close_connecting_fd(struct smb2_context *smb2, int fd)
}
}

int
smb2_service_fd(struct smb2_context *smb2, int fd, int revents)
t_socket
smb2_service_fd(struct smb2_context *smb2, t_socket fd, int revents)
{
int ret = 0;

Expand Down Expand Up @@ -806,7 +806,7 @@ smb2_service_fd(struct smb2_context *smb2, int fd, int revents)
return ret;
}

int
t_socket
smb2_service(struct smb2_context *smb2, int revents)
{
if (smb2->connecting_fds_count > 0) {
Expand Down Expand Up @@ -1096,7 +1096,7 @@ smb2_connect_async(struct smb2_context *smb2, const char *server,
return err;
}

void smb2_change_events(struct smb2_context *smb2, int fd, int events)
void smb2_change_events(struct smb2_context *smb2, t_socket fd, int events)
{
if (smb2->events == events) {
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ int smb2_readlink(struct smb2_context *smb2, const char *path,
char *buf, uint32_t len)
{
struct sync_cb_data *cb_data;
struct readlink_cb_data rl_data;
struct readlink_cb_data rl_data _U_;
int rc = 0;

cb_data = calloc(1, sizeof(struct sync_cb_data));
Expand Down

0 comments on commit 4b1ef1f

Please sign in to comment.