Anastasia Klimchuk has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/63489 )
Change subject: tests: Fix -Wmissing-prototypes warnings ......................................................................
tests: Fix -Wmissing-prototypes warnings
This patch is needed to sync compiler warning options between meson and makefile.
TEST=running the following produces no warnings: meson setup --wipe (to clean build directory) ninja test
Change-Id: Ia1ff22deb2354569f277649c6575ef2d5ffbb6e0 Signed-off-by: Anastasia Klimchuk aklm@chromium.org --- M tests/chip.c M tests/flashrom.c M tests/helpers.c M tests/layout.c M tests/libusb_wraps.c A tests/libusb_wraps.h M tests/lifecycle.c M tests/spi25.c M tests/tests.c A tests/wraps.h 10 files changed, 137 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/89/63489/1
diff --git a/tests/chip.c b/tests/chip.c index fe12533..9d442d6 100644 --- a/tests/chip.c +++ b/tests/chip.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <string.h>
+#include "tests.h" #include "chipdrivers.h" #include "flash.h" #include "io_mock.h" @@ -46,7 +47,7 @@ .buf = { 0 }, };
-int read_chip(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len) +static int read_chip(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len) { printf("Read chip called with start=0x%x, len=0x%x\n", start, len); if (!g_chip_state.unlock_calls) { @@ -60,7 +61,7 @@ return 0; }
-int write_chip(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) +static int write_chip(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { printf("Write chip called with start=0x%x, len=0x%x\n", start, len); if (!g_chip_state.unlock_calls) { @@ -74,7 +75,7 @@ return 0; }
-int unlock_chip(struct flashctx *flash) +static int unlock_chip(struct flashctx *flash) { printf("Unlock chip called\n"); g_chip_state.unlock_calls++; @@ -87,7 +88,7 @@ return 0; }
-int block_erase_chip(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen) +static int block_erase_chip(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen) { printf("Block erase called with blockaddr=0x%x, blocklen=0x%x\n", blockaddr, blocklen); if (!g_chip_state.unlock_calls) { @@ -352,7 +353,7 @@ free(newcontents); }
-size_t verify_chip_fread(void *state, void *buf, size_t size, size_t len, FILE *fp) +static size_t verify_chip_fread(void *state, void *buf, size_t size, size_t len, FILE *fp) { /* * Verify operation compares contents of the file vs contents on the chip. diff --git a/tests/flashrom.c b/tests/flashrom.c index c3508c5..cc88831 100644 --- a/tests/flashrom.c +++ b/tests/flashrom.c @@ -14,6 +14,7 @@ */
#include <include/test.h> +#include "tests.h"
#include "programmer.h"
diff --git a/tests/helpers.c b/tests/helpers.c index 4376eee..e2e652e 100644 --- a/tests/helpers.c +++ b/tests/helpers.c @@ -15,6 +15,7 @@
#include <include/test.h>
+#include "tests.h" #include "flash.h"
#include <stdint.h> diff --git a/tests/layout.c b/tests/layout.c index 1e7e31d..e71debf 100644 --- a/tests/layout.c +++ b/tests/layout.c @@ -16,6 +16,7 @@ #include <include/test.h> #include <stdio.h>
+#include "tests.h" #include "flash.h" #include "layout.h" #include "libflashrom.h" diff --git a/tests/libusb_wraps.c b/tests/libusb_wraps.c index 8f9e243..4e68ba7 100644 --- a/tests/libusb_wraps.c +++ b/tests/libusb_wraps.c @@ -17,6 +17,7 @@
#include <include/test.h> #include "io_mock.h" +#include "libusb_wraps.h"
void *__wrap_usb_dev_get_by_vid_pid_number( libusb_context *usb_ctx, uint16_t vid, uint16_t pid, unsigned int num) diff --git a/tests/libusb_wraps.h b/tests/libusb_wraps.h new file mode 100644 index 0000000..b10b8c0 --- /dev/null +++ b/tests/libusb_wraps.h @@ -0,0 +1,46 @@ +/* + * This file is part of the flashrom project. + * + * Copyright 2022 Google LLC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef LIBUSB_WRAPS_H +#define LIBUSB_WRAPS_H + +#include <libusb.h> + +void *__wrap_usb_dev_get_by_vid_pid_number( + libusb_context *usb_ctx, uint16_t vid, uint16_t pid, unsigned int num); +int __wrap_libusb_init(libusb_context **ctx); +int __wrap_libusb_open(libusb_device *dev, libusb_device_handle **devh); +int __wrap_libusb_set_auto_detach_kernel_driver(libusb_device_handle *devh, int enable); +ssize_t __wrap_libusb_get_device_list(libusb_context *ctx, libusb_device ***list); +void __wrap_libusb_free_device_list(libusb_device **list, int unref_devices); +uint8_t __wrap_libusb_get_bus_number(libusb_device *dev); +uint8_t __wrap_libusb_get_device_address(libusb_device *dev); +int __wrap_libusb_get_device_descriptor(libusb_device *dev, struct libusb_device_descriptor *desc); +int __wrap_libusb_get_config_descriptor( + libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config); +void __wrap_libusb_free_config_descriptor(struct libusb_config_descriptor *config); +int __wrap_libusb_get_configuration(libusb_device_handle *devh, int *config); +int __wrap_libusb_set_configuration(libusb_device_handle *devh, int config); +int __wrap_libusb_claim_interface(libusb_device_handle *devh, int interface_number); +int __wrap_libusb_control_transfer(libusb_device_handle *devh, uint8_t bmRequestType, + uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, + uint16_t wLength, unsigned int timeout); +int __wrap_libusb_release_interface(libusb_device_handle *devh, int interface_number); +void __wrap_libusb_close(libusb_device_handle *devh); +libusb_device *__wrap_libusb_ref_device(libusb_device *dev); +void __wrap_libusb_unref_device(libusb_device *dev); +void __wrap_libusb_exit(libusb_context *ctx); + +#endif /* LIBUSB_WRAPS_H */ diff --git a/tests/lifecycle.c b/tests/lifecycle.c index 5566b3b..183a470 100644 --- a/tests/lifecycle.c +++ b/tests/lifecycle.c @@ -17,6 +17,7 @@ #include <string.h> #include <linux/spi/spidev.h>
+#include "tests.h" #include "libflashrom.h" #include "io_mock.h" #include "programmer.h" @@ -198,13 +199,13 @@ #endif }
-int dediprog_libusb_init(void *state, libusb_context **ctx) +static int dediprog_libusb_init(void *state, libusb_context **ctx) { *ctx = not_null(); return 0; }
-int dediprog_libusb_control_transfer(void *state, +static int dediprog_libusb_control_transfer(void *state, libusb_device_handle *devh, uint8_t bmRequestType, uint8_t bRequest, @@ -243,7 +244,7 @@ char *fopen_path; };
-FILE *linux_mtd_fopen(void *state, const char *pathname, const char *mode) +static FILE *linux_mtd_fopen(void *state, const char *pathname, const char *mode) { struct linux_mtd_io_state *io_state = state;
@@ -252,7 +253,7 @@ return not_null(); }
-size_t linux_mtd_fread(void *state, void *buf, size_t size, size_t len, FILE *fp) +static size_t linux_mtd_fread(void *state, void *buf, size_t size, size_t len, FILE *fp) { struct linux_mtd_fread_mock_entry { const char *path; @@ -286,7 +287,7 @@ return 0; }
-int linux_mtd_fclose(void *state, FILE *fp) +static int linux_mtd_fclose(void *state, FILE *fp) { struct linux_mtd_io_state *io_state = state;
@@ -340,7 +341,7 @@ return 0; }
-char *linux_spi_fgets(void *state, char *buf, int len, FILE *fp) +static char *linux_spi_fgets(void *state, char *buf, int len, FILE *fp) { /* Emulate reading max buffer size from sysfs. */ const char *max_buf_size = "1048576"; diff --git a/tests/spi25.c b/tests/spi25.c index 251c98c..f57251e 100644 --- a/tests/spi25.c +++ b/tests/spi25.c @@ -15,6 +15,8 @@
#include <include/test.h>
+#include "wraps.h" +#include "tests.h" #include "programmer.h" #include "flashchips.h" #include "chipdrivers.h" diff --git a/tests/tests.c b/tests/tests.c index 3eef47e..6aabd90 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -16,6 +16,7 @@ #include <include/test.h> #include "io_mock.h" #include "tests.h" +#include "wraps.h"
#include <stdio.h> #include <string.h> diff --git a/tests/wraps.h b/tests/wraps.h new file mode 100644 index 0000000..c088d98 --- /dev/null +++ b/tests/wraps.h @@ -0,0 +1,71 @@ +/* + * This file is part of the flashrom project. + * + * Copyright 2022 Google LLC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef WRAPS_H +#define WRAPS_H + +#include <stdio.h> +#include "flash.h" + +char *__wrap_strdup(const char *s); +void __wrap_physunmap(void *virt_addr, size_t len); +void *__wrap_physmap(const char *descr, uintptr_t phys_addr, size_t len); +struct pci_dev *__wrap_pcidev_init(void *devs, int bar); +uintptr_t __wrap_pcidev_readbar(void *dev, int bar); +void __wrap_sio_write(uint16_t port, uint8_t reg, uint8_t data); +uint8_t __wrap_sio_read(uint16_t port, uint8_t reg); +int __wrap_open(const char *pathname, int flags); +int __wrap_open64(const char *pathname, int flags); +int __wrap___open64_2(const char *pathname, int flags); +int __wrap_ioctl(int fd, unsigned long int request, ...); +int __wrap_write(int fd, const void *buf, size_t sz); +int __wrap_read(int fd, void *buf, size_t sz); +FILE *__wrap_fopen(const char *pathname, const char *mode); +FILE *__wrap_fopen64(const char *pathname, const char *mode); +FILE *__wrap_fdopen(int fd, const char *mode); +int __wrap_stat(const char *path, void *buf); +int __wrap_stat64(const char *path, void *buf); +int __wrap___xstat(const char *path, void *buf); +int __wrap___xstat64(const char *path, void *buf); +int __wrap_fstat(int fd, void *buf); +int __wrap_fstat64(int fd, void *buf); +int __wrap___fxstat(int fd, void *buf); +int __wrap___fxstat64(int fd, void *buf); +char *__wrap_fgets(char *buf, int len, FILE *fp); +char *__wrap___fgets_chk(char *buf, int len, FILE *fp); +size_t __wrap_fread(void *ptr, size_t size, size_t nmemb, FILE *fp); +size_t __wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *fp); +int __wrap_fflush(FILE *fp); +int __wrap_fileno(FILE *fp); +int __wrap_fsync(int fd); +int __wrap_setvbuf(FILE *fp, char *buf, int type, size_t size); +int __wrap_fprintf(FILE *fp, const char *fmt, ...); +int __wrap___vfprintf_chk(FILE *fp, const char *fmt, va_list args); +int __wrap_fclose(FILE *fp); +int __wrap_feof(FILE *fp); +int __wrap_ferror(FILE *fp); +void __wrap_clearerr(FILE *fp); +int __wrap_rget_io_perms(void); +void __wrap_test_outb(unsigned char value, unsigned short port); +unsigned char __wrap_test_inb(unsigned short port); +void __wrap_test_outw(unsigned short value, unsigned short port); +unsigned short __wrap_test_inw(unsigned short port); +void __wrap_test_outl(unsigned int value, unsigned short port); +unsigned int __wrap_test_inl(unsigned short port); +int __wrap_spi_send_command(const struct flashctx *flash, + unsigned int writecnt, unsigned int readcnt, + const unsigned char *writearr, unsigned char *readarr); + +#endif /* WRAPS_H */