Skip to content

Commit

Permalink
Fix -Wmissing-declarations and -Wmissing-prototypes warnings
Browse files Browse the repository at this point in the history
This is a theoretical ABI change, but hopefully no third-party app is
linking against undocumented functions not part of any header file.
Also remove an unused function.

(cherry picked from commit 188b608)
  • Loading branch information
DemiMarie authored and marmarek committed Jun 22, 2024
1 parent f1e5736 commit 8db9b67
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 52 deletions.
2 changes: 1 addition & 1 deletion qrexec-lib/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC=gcc
CFLAGS := $(CFLAGS) -I. -g3 -O2 -Wall -Wextra -Werror -pie -fPIC
CFLAGS := $(CFLAGS) -I. -g3 -O2 -Wall -Wextra -Werror -pie -fPIC -Wmissing-declarations -Wmissing-prototypes
SO_VER=2
LDFLAGS+=-Wl,--no-undefined,--as-needed,-Bsymbolic -L .
.PHONY: all clean install check
Expand Down
40 changes: 0 additions & 40 deletions qrexec-lib/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,6 @@
unsigned long Crc32_ComputeBuf( unsigned long inCrc32, const void *buf,
size_t bufLen );

/*----------------------------------------------------------------------------*\
* NAME:
* Crc32_ComputeFile() - compute CRC-32 value for a file
* DESCRIPTION:
* Computes the CRC-32 value for an opened file.
* ARGUMENTS:
* file - file pointer
* outCrc32 - (out) result CRC-32 value
* RETURNS:
* err - 0 on success or -1 on error
* ERRORS:
* - file errors
\*----------------------------------------------------------------------------*/

int Crc32_ComputeFile( FILE *file, unsigned long *outCrc32 )
{
# define CRC_BUFFER_SIZE 8192
unsigned char buf[CRC_BUFFER_SIZE];
size_t bufLen;

/** accumulate crc32 from file **/
*outCrc32 = 0;
while (1) {
bufLen = fread( buf, 1, CRC_BUFFER_SIZE, file );
if (bufLen == 0) {
if (ferror(file)) {
fprintf( stderr, "error reading file\n" );
goto ERR_EXIT;
}
break;
}
*outCrc32 = Crc32_ComputeBuf( *outCrc32, buf, bufLen );
}
return( 0 );

/** error exit **/
ERR_EXIT:
return( -1 );
}

/*----------------------------------------------------------------------------*\
* NAME:
* Crc32_ComputeBuf() - computes the CRC-32 value of a memory buffer
Expand Down
3 changes: 2 additions & 1 deletion qrexec-lib/ioall.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include "libqubes-rpc-filecopy.h"

void perror_wrapper(const char * msg)
static void perror_wrapper(const char * msg)
{
int prev=errno;
perror(msg);
Expand Down
20 changes: 10 additions & 10 deletions qrexec-lib/unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void send_status_and_crc(int code, const char *last_filename);
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
#endif

_Noreturn void do_exit(int code, const char *last_filename)
static _Noreturn void do_exit(int code, const char *last_filename)
{
close(0);
send_status_and_crc(code, last_filename);
Expand Down Expand Up @@ -74,7 +74,7 @@ void set_procfs_fd(int value)
use_tmpfile = 1;
}

int wait_for_space(int fd, unsigned long how_much) {
static int wait_for_space(int fd, unsigned long how_much) {
int counter = 0;
struct statvfs fs_space;
do {
Expand All @@ -91,7 +91,7 @@ int wait_for_space(int fd, unsigned long how_much) {
}

static unsigned long crc32_sum = 0;
int read_all_with_crc(int fd, void *buf, int size) {
static int read_all_with_crc(int fd, void *buf, int size) {
int ret;
ret = read_all(fd, buf, size);
if (ret)
Expand Down Expand Up @@ -196,8 +196,8 @@ static int opendir_safe(int dirfd, char *path, const char **last_segment)
}
}

void process_one_file_reg(struct file_header *untrusted_hdr,
const char *untrusted_name)
static void process_one_file_reg(struct file_header *untrusted_hdr,
const char *untrusted_name)
{
int ret;
int fdout = -1, safe_dirfd;
Expand Down Expand Up @@ -260,8 +260,8 @@ void process_one_file_reg(struct file_header *untrusted_hdr,
}


void process_one_file_dir(struct file_header *untrusted_hdr,
const char *untrusted_name)
static void process_one_file_dir(struct file_header *untrusted_hdr,
const char *untrusted_name)
{
int safe_dirfd;
const char *last_segment;
Expand Down Expand Up @@ -291,8 +291,8 @@ void process_one_file_dir(struct file_header *untrusted_hdr,
free(path_dup);
}

void process_one_file_link(struct file_header *untrusted_hdr,
const char *untrusted_name)
static void process_one_file_link(struct file_header *untrusted_hdr,
const char *untrusted_name)
{
char untrusted_content[MAX_PATH_LENGTH];
const char *last_segment;
Expand Down Expand Up @@ -331,7 +331,7 @@ void process_one_file_link(struct file_header *untrusted_hdr,
free(path_dup);
}

void process_one_file(struct file_header *untrusted_hdr, int flags)
static void process_one_file(struct file_header *untrusted_hdr, int flags)
{
unsigned int namelen;
if (untrusted_hdr->namelen > MAX_PATH_LENGTH - 1)
Expand Down

0 comments on commit 8db9b67

Please sign in to comment.