Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ project('tqftpserv',
'c',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop Gerrit tags. We don't use Gerrit here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch seems to have various interesting and useful changes lumped together in one patch, and as it's part of the same PR as everything else none of it can be merged without agreeing to it all...

Split things into multiple patches and if possible multiple PRs.

version: '1.1',
default_options: [
'warning_level=1',
'warning_level=3',
'buildtype=release',
'werror=true'
])

prefix = get_option('prefix')

# Add specific warning flags not covered by warning_level=3
add_project_arguments('-Wsign-compare', '-Wunused-parameter', '-Wtype-limits', '-Wimplicit-function-declaration', language : 'c')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Why did you select these flags?


zstd_dep = dependency('libzstd')
add_project_arguments('-DHAVE_ZSTD', language : 'c')

Expand Down
14 changes: 7 additions & 7 deletions tqftpserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ static ssize_t tftp_send_data(struct tftp_client *client,
unsigned int block, size_t offset, size_t response_size)
{
ssize_t len;
size_t send_len;
char *buf = client->blk_buf;
char *p = buf;
ssize_t send_len;
uint8_t *buf = client->blk_buf;
uint8_t *p = buf;

*p++ = 0;
*p++ = OP_DATA;
Expand Down Expand Up @@ -108,7 +108,7 @@ static int tftp_send_ack(int sock, int block)
return send(sock, &ack, sizeof(ack), 0);
}

static int tftp_send_oack(int sock, size_t *blocksize, size_t *tsize,
static int tftp_send_oack(int sock, size_t *blocksize, ssize_t *tsize,
size_t *wsize, unsigned int *timeoutms, size_t *rsize,
off_t *seek)
{
Expand Down Expand Up @@ -334,7 +334,7 @@ static void handle_rrq(const char *buf, size_t len, struct sockaddr_qrtr *sq)

if (do_oack) {
tftp_send_oack(client->sock, &blksize,
tsize ? (size_t*)&tsize : NULL,
tsize ? &tsize : NULL,
wsize ? &wsize : NULL,
&client->timeoutms,
rsize ? &rsize : NULL,
Expand Down Expand Up @@ -430,7 +430,7 @@ static void handle_wrq(const char *buf, size_t len, struct sockaddr_qrtr *sq)

if (do_oack) {
tftp_send_oack(client->sock, &blksize,
tsize ? (size_t*)&tsize : NULL,
tsize ? &tsize : NULL,
wsize ? &wsize : NULL,
&client->timeoutms,
rsize ? &rsize : NULL,
Expand Down Expand Up @@ -602,7 +602,7 @@ static void client_close_and_free(struct tftp_client *client)
free(client);
}

int main(int argc, char **argv)
int main()
{
struct tftp_client *client;
struct tftp_client *next;
Expand Down
7 changes: 6 additions & 1 deletion translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
/*
* Copyright (c) 2019, Linaro Ltd.
*/

/* For asprintf */
#define _GNU_SOURCE

#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
Expand Down Expand Up @@ -232,7 +236,8 @@ static int open_maybe_compressed(const char *path)
if (access(path, F_OK) == 0)
return open(path, O_RDONLY);

asprintf(&path_with_zstd_extension, "%s%s", path, ZSTD_EXTENSION);
if (asprintf(&path_with_zstd_extension, "%s%s", path, ZSTD_EXTENSION) == -1)
return -1;

if (access(path_with_zstd_extension, F_OK) == 0)
fd = zstd_decompress_file(path_with_zstd_extension);
Expand Down
2 changes: 1 addition & 1 deletion zstd-decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int zstd_decompress_file(const char *filename)
return -1;
}

if (write(output_file_fd, decompressed_buffer, decompressed_size) != decompressed_size) {
if (write(output_file_fd, decompressed_buffer, decompressed_size) != (ssize_t)decompressed_size) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change decompressed_size to size_t or ssize_t.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not done. I've asked to change its type to one of size_t types.

perror("write failed");
close(output_file_fd);
free(decompressed_buffer);
Expand Down
2 changes: 1 addition & 1 deletion zstd-decompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int zstd_decompress_file(const char *filename);
#else
static int zstd_decompress_file(const char *filename)
{
fprintf(stderr, "Built without ZSTD support\n");
fprintf(stderr, "Built without ZSTD support: %s\n", filename);
return -1;
}
#endif
Expand Down