Fix problems regarding function prototypes

In C, you can call functions which do not have prototypes
available; however, if the implied prototype doesn't match
the actual prototype, the behavior is undefined.  These changes
make mesaflash compile cleanly even when these prototype-checking
compiler flags are enabled (and enables them by default):
    -Werror=missing-prototypes
    -Werror=strict-prototypes
    -Werror=implicit-function-declaration
This commit is contained in:
Jeff Epler 2016-11-21 21:09:24 -06:00
parent c3f23baf64
commit 934769e0cc
18 changed files with 80 additions and 66 deletions

View file

@ -30,7 +30,7 @@ OPT = -O0
#DEBUG = -g -pedantic -Wall -Wextra
#DEBUG = -g -Wall -Wextra
DEBUG = -g
DEBUG = -g -Werror=missing-prototypes -Werror=strict-prototypes -Werror=implicit-function-declaration
ifeq ($(TARGET),linux)
INCLUDE = -I/usr/include

View file

@ -22,6 +22,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include "types.h"
#include "bitfile.h"
#include "eeprom.h"
#include "eeprom_local.h"
#include "eeprom_remote.h"

View file

@ -258,7 +258,7 @@ static u8 recv_byte_io(llio_t *self) {
// spi access via epp on board 7i43 with EPPIO firmware
void wait_for_data_epp(llio_t *self) {
static void wait_for_data_epp(llio_t *self) {
board_t *board = self->board;
u32 i = 0;
u8 data = 0;

View file

@ -136,7 +136,7 @@ static inline void epp_write32(board_t *board, u32 data) {
}
}
int epp_read(llio_t *self, u32 addr, void *buffer, int size) {
static int epp_read(llio_t *self, u32 addr, void *buffer, int size) {
int bytes_remaining = size;
board_t *board = self->board;
@ -162,7 +162,7 @@ int epp_read(llio_t *self, u32 addr, void *buffer, int size) {
return 1; // success
}
int epp_write(llio_t *self, u32 addr, void *buffer, int size) {
static int epp_write(llio_t *self, u32 addr, void *buffer, int size) {
int bytes_remaining = size;
board_t *board = self->board;
@ -188,7 +188,7 @@ int epp_write(llio_t *self, u32 addr, void *buffer, int size) {
return 1;
}
int epp_program_fpga(llio_t *self, char *bitfile_name) {
static int epp_program_fpga(llio_t *self, char *bitfile_name) {
board_t *board = self->board;
int bindex, bytesread;
char part_name[32];
@ -244,7 +244,7 @@ int epp_program_fpga(llio_t *self, char *bitfile_name) {
}
// return 0 if the board has been reset, -errno if not
int epp_reset(llio_t *self) {
static int epp_reset(llio_t *self) {
board_t *board = self->board;
u8 byte;

View file

@ -64,7 +64,7 @@ inline int eth_recv_packet(void *buffer, int size) {
return recvfrom(sd, (char*) buffer, size, 0, (struct sockaddr *) &src_addr, &len);
}
static void eth_socket_nonblocking() {
static void eth_socket_nonblocking(void) {
#ifdef __linux__
int val = fcntl(sd, F_GETFL);
@ -77,7 +77,7 @@ static void eth_socket_nonblocking() {
#endif
}
static void eth_socket_blocking() {
static void eth_socket_blocking(void) {
#ifdef __linux__
int val = fcntl(sd, F_GETFL);
@ -94,7 +94,7 @@ void eth_socket_set_dest_ip(char *addr_name) {
dst_addr.sin_addr.s_addr = inet_addr(addr_name);
}
static char *eth_socket_get_src_ip() {
static char *eth_socket_get_src_ip(void) {
return inet_ntoa(src_addr.sin_addr);
}

View file

@ -22,6 +22,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include "../anyio.h"
#include "../sserial_module.h"
#ifdef __linux__
@ -38,7 +39,7 @@ static int instance = 0;
static int delay_flag;
static int delay = 50;
static int verbose_flag;
static board_access_t access;
static board_access_t board_access;
static struct option long_options[] = {
{"device", required_argument, 0, 'd'},
@ -48,7 +49,7 @@ static struct option long_options[] = {
{0, 0, 0, 0}
};
void print_short_usage() {
static void print_short_usage(void) {
printf("Example program for writing analog output on pci boards\n");
printf("Syntax:\n");
printf(" pci_analog_write --device str [--instance i] [--delay d] [--verbose]\n");
@ -58,7 +59,7 @@ void print_short_usage() {
printf(" --verbose printf additional info during execution\n");
}
int process_cmd_line(int argc, char *argv[]) {
static int process_cmd_line(int argc, char *argv[]) {
int c;
while (1) {
@ -87,9 +88,9 @@ int process_cmd_line(int argc, char *argv[]) {
printf("Error: multiply --device option\n");
exit(-1);
}
access.device_name = optarg;
board_access.device_name = optarg;
for (i = 0; optarg[i] != '\0'; i++)
access.device_name[i] = toupper(access.device_name[i]);
board_access.device_name[i] = toupper(board_access.device_name[i]);
device_flag++;
}
@ -143,18 +144,18 @@ int main(int argc, char *argv[]) {
return -1;
}
access.verbose = verbose_flag;
board_access.verbose = verbose_flag;
if (anyio_init(&access) != 0) { // init library
if (anyio_init(&board_access) != 0) { // init library
return -1;
}
ret = anyio_find_dev(&access); // find board
ret = anyio_find_dev(&board_access); // find board
if (ret < 0) {
return -1;
}
board = anyio_get_dev(&access, 1); // if found the get board handle
board = anyio_get_dev(&board_access, 1); // if found the get board handle
if (board == NULL) {
printf("No %s board found\n", access.device_name);
printf("No %s board found\n", board_access.device_name);
return -1;
}
@ -184,7 +185,7 @@ int main(int argc, char *argv[]) {
board->close(board); // close board communication
anyio_cleanup(&access); // close library
anyio_cleanup(&board_access); // close library
return 0;
}

View file

@ -22,6 +22,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include "../anyio.h"
#include "../encoder_module.h"
#ifdef __linux__
@ -38,7 +39,7 @@ static int instance = 0;
static int delay_flag;
static int delay = 50;
static int verbose_flag;
static board_access_t access;
static board_access_t board_access;
static struct option long_options[] = {
{"device", required_argument, 0, 'd'},
@ -48,7 +49,7 @@ static struct option long_options[] = {
{0, 0, 0, 0}
};
void print_short_usage() {
static void print_short_usage(void) {
printf("Example program forreading encoder on pci boards\n");
printf("Syntax:\n");
printf(" pci_encoder_read --device str [--instance i] [--delay d] [--verbose]\n");
@ -58,7 +59,7 @@ void print_short_usage() {
printf(" --verbose printf additional info during execution\n");
}
int process_cmd_line(int argc, char *argv[]) {
static int process_cmd_line(int argc, char *argv[]) {
int c;
while (1) {
@ -87,9 +88,9 @@ int process_cmd_line(int argc, char *argv[]) {
printf("Error: multiply --device option\n");
exit(-1);
}
access.device_name = optarg;
board_access.device_name = optarg;
for (i = 0; optarg[i] != '\0'; i++)
access.device_name[i] = toupper(access.device_name[i]);
board_access.device_name[i] = toupper(board_access.device_name[i]);
device_flag++;
}
@ -141,18 +142,18 @@ int main(int argc, char *argv[]) {
return -1;
}
access.verbose = verbose_flag;
board_access.verbose = verbose_flag;
if (anyio_init(&access) != 0) { // init library
if (anyio_init(&board_access) != 0) { // init library
return -1;
}
ret = anyio_find_dev(&access); // find board
ret = anyio_find_dev(&board_access); // find board
if (ret < 0) {
return -1;
}
board = anyio_get_dev(&access, 1); // if found the get board handle
board = anyio_get_dev(&board_access, 1); // if found the get board handle
if (board == NULL) {
printf("No %s board found\n", access.device_name);
printf("No %s board found\n", board_access.device_name);
return -1;
}
@ -176,7 +177,7 @@ int main(int argc, char *argv[]) {
fail0:
board->close(board); // close board communication
anyio_cleanup(&access); // close library
anyio_cleanup(&board_access); // close library
return 0;
}

View file

@ -46,7 +46,7 @@ void hm2_read_idrom(hostmot2_t *hm2) {
}
}
const char *hm2_hz_to_mhz(u32 freq_hz) {
static const char *hm2_hz_to_mhz(u32 freq_hz) {
static char mhz_str[20];
int r;
int freq_mhz, freq_mhz_fractional;
@ -62,7 +62,7 @@ const char *hm2_hz_to_mhz(u32 freq_hz) {
return mhz_str;
}
const char *hm2_get_general_function_name(int gtag) {
static const char *hm2_get_general_function_name(int gtag) {
switch (gtag) {
case HM2_GTAG_IRQ_LOGIC: return "IRQ logic";
case HM2_GTAG_WATCHDOG: return "Watchdog";

View file

@ -90,6 +90,8 @@ void hm2_print_pin_file(llio_t *llio, int xml_flag);
void hm2_set_pin_source(hostmot2_t *hm2, int pin_number, u8 source);
void hm2_set_pin_direction(hostmot2_t *hm2, int pin_number, u8 direction);
void sserial_module_init(llio_t *llio);
void hm2_set_pin_source(hostmot2_t *hm2, int pin_number, u8 source);
void hm2_set_pin_direction(hostmot2_t *hm2, int pin_number, u8 direction);
#endif

4
lbp.c
View file

@ -99,7 +99,7 @@ int lbp_write(u16 addr, void *buffer) {
return 0;
}
void lbp_print_info() {
void lbp_print_info(void) {
u8 data;
data = lbp_read_ctrl(LBP_CMD_READ_VERSION);
@ -122,7 +122,7 @@ void lbp_init(board_access_t *access) {
#endif
}
void lbp_release() {
void lbp_release(void) {
#ifdef __linux__
close(sd);
#endif

4
lbp.h
View file

@ -85,9 +85,9 @@ int lbp_recv(void *packet, int size);
u8 lbp_read_ctrl(u8 cmd);
int lbp_read(u16 addr, void *buffer);
int lbp_write(u16 addr, void *buffer);
void lbp_print_info();
void lbp_print_info(void);
void lbp_init(board_access_t *access);
void lbp_release();
void lbp_release(void);
#endif

View file

@ -142,5 +142,5 @@ void lbp16_init(int board_type) {
}
}
void lbp_cleanup(int board_type) {
void lbp16_cleanup(int board_type) {
}

View file

@ -89,7 +89,7 @@ static struct option long_options[] = {
{0, 0, 0, 0}
};
void print_short_usage() {
static void print_short_usage(void) {
printf("\nMesaflash version 3.3.0~pre (built on %s %s with libpci %s)\n", __DATE__, __TIME__, PCILIB_VERSION);
printf("Configuration and diagnostic tool for Mesa Electronics PCI(E)/ETH/EPP/USB boards\n");
printf("(C) 2013-2015 Michael Geszkiewicz (contact: micges@wp.pl)\n");
@ -97,7 +97,7 @@ void print_short_usage() {
printf("Try 'mesaflash --help' for more information\n");
}
void print_usage() {
static void print_usage(void) {
printf("Syntax:\n");
printf(" mesaflash --device device_name [options]\n");
printf(" mesaflash --device device_name [options] --write filename\n");
@ -141,7 +141,7 @@ void print_usage() {
printf(" --help print this help message\n");
}
int process_cmd_line(int argc, char *argv[]) {
static int process_cmd_line(int argc, char *argv[]) {
int c;
while (1) {

View file

@ -20,6 +20,7 @@
#include <sys/mman.h>
#include <sys/io.h>
#include <pci/pci.h>
#include <sys/time.h>
#elif _WIN32
#include <windows.h>
#include "libpci/pci.h"
@ -46,6 +47,9 @@ static int memfd = -1;
struct pci_access *pacc;
static u8 file_buffer[SECTOR_SIZE];
static int pci_read(llio_t *self, u32 addr, void *buffer, int size);
static int pci_write(llio_t *self, u32 addr, void *buffer, int size);
u16 setup_eeprom_5i20[256] = {
0x9030, // DEVICE ID
0x10B5, // VENDOR ID
@ -383,7 +387,7 @@ static u16 plx9030_read_eeprom_word(board_t *board, u8 reg) {
return tdata;
}
void pci_plx9030_bridge_eeprom_setup_read(board_t *board) {
static void pci_plx9030_bridge_eeprom_setup_read(board_t *board) {
int i;
char *bridge_name = "Unknown";
@ -663,7 +667,7 @@ static int plx905x_reset(llio_t *self) {
return 0;
}
void memcpy32(void *vdest, void *vsrc, int size) {
static void memcpy32(void *vdest, void *vsrc, int size) {
volatile u32 *dest = (volatile u32*)vdest;
volatile u32 *src = (volatile u32*)vsrc;
while(size) {
@ -674,14 +678,14 @@ void memcpy32(void *vdest, void *vsrc, int size) {
}
}
int pci_read(llio_t *self, u32 addr, void *buffer, int size) {
static int pci_read(llio_t *self, u32 addr, void *buffer, int size) {
board_t *board = self->board;
assert(size % 4 == 0);
memcpy32(buffer, board->base + addr, size/4);
return 0;
}
int pci_write(llio_t *self, u32 addr, void *buffer, int size) {
static int pci_write(llio_t *self, u32 addr, void *buffer, int size) {
board_t *board = self->board;
assert(size % 4 == 0);
memcpy32(board->base + addr, buffer, size/4);

View file

@ -24,7 +24,9 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include <poll.h>
#include <sys/poll.h>
#include <unistd.h>
#include "types.h"
#include "anyio.h"
#include "serial_boards.h"

View file

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#include <ctype.h>
#include <fcntl.h>
#include <linux/spi/spidev.h>
#include <stdbool.h>
@ -28,7 +29,9 @@
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "types.h"
#include "eeprom.h"
#include "eeprom_local.h"
#include "spi_boards.h"
#include "common.h"
@ -110,7 +113,7 @@ void spi_boards_cleanup(board_access_t *access) {
if(sd != -1) close(sd);
}
void reorderBuffer(char *pBuf, int numInts)
static void reorderBuffer(char *pBuf, int numInts)
{
int lcv;
for (lcv = 0; lcv < numInts; lcv++)
@ -125,7 +128,7 @@ void reorderBuffer(char *pBuf, int numInts)
}
}
int spi_read(llio_t *self, u32 addr, void *buffer, int size) {
static int spi_read(llio_t *self, u32 addr, void *buffer, int size) {
if(size % 4 != 0) return -1;
int numInts = 1+size/4;
u32 trxbuf[numInts];
@ -154,7 +157,7 @@ int spi_read(llio_t *self, u32 addr, void *buffer, int size) {
return 0;
}
int spi_write(llio_t *self, u32 addr, void *buffer, int size) {
static int spi_write(llio_t *self, u32 addr, void *buffer, int size) {
if(size % 4 != 0) return -1;
int numInts = 1+size/4;
u32 txbuf[numInts];

View file

@ -68,40 +68,40 @@ static void disable_sserial_pins(llio_t *llio) {
}
}
void sslbp_send_local_cmd(sserial_module_t *ssmod, int interface, u32 cmd) {
static void sslbp_send_local_cmd(sserial_module_t *ssmod, int interface, u32 cmd) {
ssmod->board->llio.write(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_CMD + interface*0x40, &(cmd), sizeof(u32));
}
u32 sslbp_read_local_cmd(sserial_module_t *ssmod, int interface) {
static u32 sslbp_read_local_cmd(sserial_module_t *ssmod, int interface) {
u32 data;
ssmod->board->llio.read(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_CMD + interface*0x40, &(data), sizeof(u32));
return data;
}
u8 sslbp_read_data(sserial_module_t *ssmod, int interface) {
static u8 sslbp_read_data(sserial_module_t *ssmod, int interface) {
u32 data;
ssmod->board->llio.read(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_DATA + interface*0x40, &(data), sizeof(u32));
return data & 0xFF;
}
void sslbp_wait_complete(sserial_module_t *ssmod, int interface) {
static void sslbp_wait_complete(sserial_module_t *ssmod, int interface) {
while (sslbp_read_local_cmd(ssmod, interface) != 0) {}
}
void sslbp_send_remote_cmd(sserial_module_t *ssmod, int interface, int channel, u32 cmd) {
static void sslbp_send_remote_cmd(sserial_module_t *ssmod, int interface, int channel, u32 cmd) {
ssmod->board->llio.write(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_CS + interface*0x40 + channel*4, &(cmd), sizeof(u32));
}
u8 sslbp_read_local8(sserial_module_t *ssmod, int interface, u32 addr) {
static u8 sslbp_read_local8(sserial_module_t *ssmod, int interface, u32 addr) {
sslbp_send_local_cmd(ssmod, interface, SSLBP_CMD_READ(addr));
sslbp_wait_complete(ssmod, interface);
return sslbp_read_data(ssmod, interface);
}
u32 sslbp_read_local32(sserial_module_t *ssmod, int interface, u32 addr) {
static u32 sslbp_read_local32(sserial_module_t *ssmod, int interface, u32 addr) {
int byte = 4;
u32 ret = 0;
@ -110,7 +110,7 @@ u32 sslbp_read_local32(sserial_module_t *ssmod, int interface, u32 addr) {
return ret;
}
u8 sslbp_read_remote8(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
static u8 sslbp_read_remote8(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
u32 data;
sslbp_send_remote_cmd(ssmod, interface, channel, ((LBP_CMD_READ | LBP_ADDR_AUTO_INC) << 24) | addr);
@ -120,7 +120,7 @@ u8 sslbp_read_remote8(sserial_module_t *ssmod, int interface, int channel, u32 a
return data & 0xFF;
}
u16 sslbp_read_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
static u16 sslbp_read_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
int byte;
u16 ret = 0;
@ -129,7 +129,7 @@ u16 sslbp_read_remote16(sserial_module_t *ssmod, int interface, int channel, u32
return ret;
}
u32 sslbp_read_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
static u32 sslbp_read_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
int byte;
u32 ret = 0;
@ -138,7 +138,7 @@ u32 sslbp_read_remote32(sserial_module_t *ssmod, int interface, int channel, u32
return ret;
}
void sslbp_write_remote8(sserial_module_t *ssmod, int interface, int channel, u32 addr, u8 data) {
static void sslbp_write_remote8(sserial_module_t *ssmod, int interface, int channel, u32 addr, u8 data) {
u32 d = data;
sslbp_send_remote_cmd(ssmod, interface, channel, ((LBP_CMD_WRITE | LBP_ARGS_8BIT | LBP_ADDR_AUTO_INC) << 24) | addr);
@ -147,7 +147,7 @@ void sslbp_write_remote8(sserial_module_t *ssmod, int interface, int channel, u3
sslbp_wait_complete(ssmod, interface);
}
void sslbp_write_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr, u16 data) {
static void sslbp_write_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr, u16 data) {
u32 d = data;
sslbp_send_remote_cmd(ssmod, interface, channel, ((LBP_CMD_WRITE | LBP_ARGS_16BIT | LBP_ADDR_AUTO_INC) << 24) | addr);
@ -156,7 +156,7 @@ void sslbp_write_remote16(sserial_module_t *ssmod, int interface, int channel, u
sslbp_wait_complete(ssmod, interface);
}
void sslbp_write_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr, u32 data) {
static void sslbp_write_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr, u32 data) {
u32 d = data;
sslbp_send_remote_cmd(ssmod, interface, channel, ((LBP_CMD_WRITE | LBP_ARGS_32BIT | LBP_ADDR_AUTO_INC) << 24) | addr);
@ -165,7 +165,7 @@ void sslbp_write_remote32(sserial_module_t *ssmod, int interface, int channel, u
sslbp_wait_complete(ssmod, interface);
}
u16 sslbp_read_nv_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
static u16 sslbp_read_nv_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
u16 data;
u32 cmd = LBP_CMD_READ_NV << 24;
@ -185,7 +185,7 @@ u16 sslbp_read_nv_remote16(sserial_module_t *ssmod, int interface, int channel,
return data;
}
u32 sslbp_read_nv_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
static u32 sslbp_read_nv_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
u32 data;
u32 cmd = LBP_CMD_READ_NV << 24;
@ -205,7 +205,7 @@ u32 sslbp_read_nv_remote32(sserial_module_t *ssmod, int interface, int channel,
return data;
}
void sslbp_read_remote_bytes(sserial_module_t *ssmod, int interface, int channel, u32 addr, void *buffer, int size) {
static void sslbp_read_remote_bytes(sserial_module_t *ssmod, int interface, int channel, u32 addr, void *buffer, int size) {
char *ptr = (char *) buffer;
while (size != 0) {

View file

@ -33,7 +33,7 @@ extern board_t boards[MAX_BOARDS];
extern int boards_count;
static u8 file_buffer[SECTOR_SIZE];
int usb_read(llio_t *self, u32 addr, void *buffer, int size) {
static int usb_read(llio_t *self, u32 addr, void *buffer, int size) {
while (size > 0) {
lbp_read(addr & 0xFFFF, buffer);
addr += 4;
@ -43,7 +43,7 @@ int usb_read(llio_t *self, u32 addr, void *buffer, int size) {
return 0;
}
int usb_write(llio_t *self, u32 addr, void *buffer, int size) {
static int usb_write(llio_t *self, u32 addr, void *buffer, int size) {
while (size > 0) {
lbp_write(addr & 0xFFFF, buffer);
addr += 4;