From patchwork Wed Jan 27 08:57:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQffw346Nz9sWD for ; Wed, 27 Jan 2021 21:17:28 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffv3JRszDqkJ for ; Wed, 27 Jan 2021 21:17:27 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffJ12xdzDqqD for ; Wed, 27 Jan 2021 21:16:55 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 236E3AE80274; Wed, 27 Jan 2021 03:58:02 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:40 +1100 Message-Id: <20210127085752.120571-2-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 01/13] helpers: Define MIN() X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" We already have MAX() defined, add MIN() to the common helpers header. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Thomas Huth Reviewed-by: David Gibson --- include/helpers.h | 1 + lib/libtpm/tcgbios.c | 2 -- lib/libtpm/tpm_drivers.c | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/helpers.h b/include/helpers.h index 112184f203f0..898c02cf524b 100644 --- a/include/helpers.h +++ b/include/helpers.h @@ -53,5 +53,6 @@ extern unsigned long SLOF_get_vtpm_unit(void); #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define ROUNDUP(x,v) ((((x) + ((v) - 1)) / (v)) * (v)) #define MAX(x,y) ((x) > (y) ? (x) : (y)) +#define MIN(x,y) ((x) < (y) ? (x) : (y)) #endif diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c index ee052e102092..8e808115bc59 100644 --- a/lib/libtpm/tcgbios.c +++ b/lib/libtpm/tcgbios.c @@ -43,8 +43,6 @@ #define dprintf(_x ...) #endif -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - static struct { unsigned tpm_probed:1; unsigned tpm_found:1; diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c index 50051767a13a..0e13561d0fa0 100644 --- a/lib/libtpm/tpm_drivers.c +++ b/lib/libtpm/tpm_drivers.c @@ -30,8 +30,6 @@ #define dprintf(_x ...) #endif -#define MIN(a, b) ((a) > (b) ? (b) : (a)) - /* layout of the command request queue for vTPM; all fields are big endian */ struct crq { uint8_t valid; From patchwork Wed Jan 27 08:57:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432136 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQfg224JJz9sWD for ; Wed, 27 Jan 2021 21:17:34 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfg20B3BzDqlg for ; Wed, 27 Jan 2021 21:17:34 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffJ0QczzDqkL for ; Wed, 27 Jan 2021 21:16:55 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 6E42BAE80275; Wed, 27 Jan 2021 03:58:05 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:41 +1100 Message-Id: <20210127085752.120571-3-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 02/13] libc: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy --- lib/libc/stdio/vsnprintf.c | 15 ++++++++------- lib/libc/string/memmove.c | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c index 21dd04dfe46f..1a44301f74da 100644 --- a/lib/libc/stdio/vsnprintf.c +++ b/lib/libc/stdio/vsnprintf.c @@ -25,15 +25,15 @@ static int print_str_fill(char **buffer, size_t bufsize, char *sizec, const char *str, char c) { - int i, sizei, len; + unsigned i, sizei, len; char *bstart = *buffer; sizei = strtoul(sizec, NULL, 10); len = strlen(str); if (sizei > len) { for (i = 0; - (i < (sizei - len)) && ((*buffer - bstart) < bufsize); - i++) { + (i < (sizei - len)) && ((*buffer - bstart) < (int)bufsize); + i++) { **buffer = c; *buffer += 1; } @@ -47,7 +47,7 @@ print_str(char **buffer, size_t bufsize, const char *str) char *bstart = *buffer; size_t i; - for (i = 0; (i < strlen(str)) && ((*buffer - bstart) < bufsize); i++) { + for (i = 0; (i < strlen(str)) && ((*buffer - bstart) < (int)bufsize); i++) { **buffer = str[i]; *buffer += 1; } @@ -112,7 +112,7 @@ print_fill(char **buffer, size_t bufsize, char *sizec, unsigned long size, len = print_intlen(size, base) + optlen; if (sizei > len) { for (i = 0; - (i < (sizei - len)) && ((*buffer - bstart) < bufsize); + (i < (sizei - len)) && ((*buffer - bstart) < (int)bufsize); i++) { **buffer = c; *buffer += 1; @@ -143,7 +143,7 @@ print_format(char **buffer, size_t bufsize, const char *format, void *var) form++; } - while ((*form != '\0') && ((*buffer - start) < bufsize)) { + while ((*form != '\0') && ((*buffer - start) < (int)bufsize)) { switch(*form) { case 'u': case 'd': @@ -163,6 +163,7 @@ print_format(char **buffer, size_t bufsize, const char *format, void *var) break; case 'X': upper = true; + /* fallthrough */ case 'x': sizec[i] = '\0'; value = (unsigned long) var & convert[length_mod]; @@ -260,7 +261,7 @@ vsnprintf(char *buffer, size_t bufsize, const char *format, va_list arg) /* Leave one space for NULL character */ bufsize--; - while(*ptr != '\0' && (buffer - bstart) < bufsize) + while(*ptr != '\0' && (buffer - bstart) < (int)bufsize) { if(*ptr == '%') { char formstr[20]; diff --git a/lib/libc/string/memmove.c b/lib/libc/string/memmove.c index 3acf1a973bbe..9d0962847296 100644 --- a/lib/libc/string/memmove.c +++ b/lib/libc/string/memmove.c @@ -18,7 +18,7 @@ memmove(void *dest, const void *src, size_t n) { char *cdest; const char *csrc; - int i; + size_t i; /* Do the buffers overlap in a bad way? */ if (src < dest && src + n >= dest) { From patchwork Wed Jan 27 08:57:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432126 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQff55Mhhz9sWD for ; Wed, 27 Jan 2021 21:16:45 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQff50yqhzDqkL for ; Wed, 27 Jan 2021 21:16:45 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdh5NnwzDqjW for ; Wed, 27 Jan 2021 21:16:19 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 81BE5AE80276; Wed, 27 Jan 2021 03:58:07 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:42 +1100 Message-Id: <20210127085752.120571-4-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 03/13] elf: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy --- include/libelf.h | 6 +++--- lib/libelf/elf.c | 2 +- lib/libelf/elf32.c | 4 ++-- lib/libelf/elf64.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/libelf.h b/include/libelf.h index 48ff4d7beb68..29a4d049a096 100644 --- a/include/libelf.h +++ b/include/libelf.h @@ -96,9 +96,9 @@ void elf_relocate64(void *file_addr, signed long offset); int elf_forth_claim(void *addr, long size); -long elf_get_file_size(const void *buffer, const long buffer_size); -long elf_get_file_size32(const void *buffer, const long buffer_size); -long elf_get_file_size64(const void *buffer, const long buffer_size); +long elf_get_file_size(const void *buffer, const unsigned long buffer_size); +long elf_get_file_size32(const void *buffer, const unsigned long buffer_size); +long elf_get_file_size64(const void *buffer, const unsigned long buffer_size); #ifdef __BIG_ENDIAN__ #define elf64_to_cpu(x, ehdr) ((ehdr)->ei_data == ELFDATA2MSB ? (x) : bswap_64(x)) diff --git a/lib/libelf/elf.c b/lib/libelf/elf.c index d3684545aef7..f6a052ef3c9e 100644 --- a/lib/libelf/elf.c +++ b/lib/libelf/elf.c @@ -202,7 +202,7 @@ elf_get_base_addr(void *file_addr) * buffer larger than the size of the file * @return The size of the ELF image or < 0 for error */ -long elf_get_file_size(const void *buffer, const long buffer_size) +long elf_get_file_size(const void *buffer, const unsigned long buffer_size) { const struct ehdr *ehdr = (const struct ehdr *)buffer; diff --git a/lib/libelf/elf32.c b/lib/libelf/elf32.c index 64ea386a96da..b213a6f9ca17 100644 --- a/lib/libelf/elf32.c +++ b/lib/libelf/elf32.c @@ -212,13 +212,13 @@ elf_byteswap_header32(void *file_addr) * file. * @return Return -1 on error, size of file otherwise. */ -long elf_get_file_size32(const void *buffer, const long buffer_size) +long elf_get_file_size32(const void *buffer, const unsigned long buffer_size) { const struct ehdr32 *ehdr = (const struct ehdr32 *) buffer; const uint8_t *buffer_end = buffer + buffer_size; const struct phdr32 *phdr; const struct shdr32 *shdr; - long elf_size = -1; + unsigned long elf_size = -1; uint16_t entsize; unsigned i; diff --git a/lib/libelf/elf64.c b/lib/libelf/elf64.c index 0f302679f784..eb4cc3a7eab3 100644 --- a/lib/libelf/elf64.c +++ b/lib/libelf/elf64.c @@ -389,7 +389,7 @@ elf_apply_all_rela64(void *file_addr, signed long offset, struct shdr64 *shdrs, struct rela *relaentry; struct sym64 *symtabentry; uint32_t symbolidx; - int i; + unsigned i; /* If the referenced section has not been allocated, then it has * not been loaded and thus does not need to be relocated. */ @@ -481,13 +481,13 @@ uint32_t elf_get_eflags_64(void *file_addr) * file. * @return Return -1 on error, size of file otherwise. */ -long elf_get_file_size64(const void *buffer, const long buffer_size) +long elf_get_file_size64(const void *buffer, const unsigned long buffer_size) { const struct ehdr64 *ehdr = (const struct ehdr64 *) buffer; const uint8_t *buffer_end = buffer + buffer_size; const struct phdr64 *phdr; const struct shdr64 *shdr; - long elf_size = -1; + unsigned elf_size = (unsigned)-1; uint16_t entsize; unsigned i; From patchwork Wed Jan 27 08:57:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432132 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQfff6kPHz9sWD for ; Wed, 27 Jan 2021 21:17:14 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfff1ZmDzDqkX for ; Wed, 27 Jan 2021 21:17:14 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQff81Mr2zDqjp for ; Wed, 27 Jan 2021 21:16:47 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 913FAAE80277; Wed, 27 Jan 2021 03:58:09 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:43 +1100 Message-Id: <20210127085752.120571-5-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 04/13] usb: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Thomas Huth --- lib/libusb/usb-core.c | 4 ++-- lib/libusb/usb-hid.c | 2 +- lib/libusb/usb-ohci.c | 12 +++++------- lib/libusb/usb-xhci.c | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/libusb/usb-core.c b/lib/libusb/usb-core.c index 4c720ce2f85b..6ad8028d03a2 100644 --- a/lib/libusb/usb-core.c +++ b/lib/libusb/usb-core.c @@ -18,7 +18,7 @@ #ifdef DEBUG #define dprintf(_x ...) do { printf(_x); } while(0) #else -#define dprintf(_x ...) +#define dprintf(_x ...) do {} while (0) #endif #define __unused __attribute__((unused)) @@ -386,7 +386,7 @@ int usb_hid_exit(void *vdev) int usb_msc_init(void *vdev) { struct usb_dev *dev; - int i; + unsigned i; dev = (struct usb_dev *) vdev; dprintf("%s: enter %x\n", __func__, dev->class); diff --git a/lib/libusb/usb-hid.c b/lib/libusb/usb-hid.c index 1ea9ff235f58..ce87d2194163 100644 --- a/lib/libusb/usb-hid.c +++ b/lib/libusb/usb-hid.c @@ -390,7 +390,7 @@ uint32_t *kbd_buffer; int usb_hid_kbd_init(struct usb_dev *dev) { - int i; + unsigned i; uint8_t key[8]; usb_hid_set_protocol(dev, 0); diff --git a/lib/libusb/usb-ohci.c b/lib/libusb/usb-ohci.c index d06c754d184e..3f2ecf327444 100644 --- a/lib/libusb/usb-ohci.c +++ b/lib/libusb/usb-ohci.c @@ -21,7 +21,7 @@ #ifdef OHCI_DEBUG #define dprintf(_x ...) do { printf(_x); } while(0) #else -#define dprintf(_x ...) +#define dprintf(_x ...) do {} while (0) #endif #undef OHCI_DEBUG_PACKET @@ -29,7 +29,7 @@ #ifdef OHCI_DEBUG_PACKET #define dpprintf(_x ...) do { printf(_x); } while(0) #else -#define dpprintf(_x ...) +#define dpprintf(_x ...) do {} while (0) #endif @@ -199,10 +199,7 @@ static void ohci_hub_check_ports(struct ohci_hcd *ohcd) } if (port_status & RH_PS_PESC) { port_clear |= RH_PS_PESC; - if (port_status & RH_PS_PES) - dprintf("enabled\n"); - else - dprintf("disabled\n"); + dprintf((port_status & RH_PS_PES) ? "enabled\n" : "disabled\n"); } if (port_status & RH_PS_PSSC) { port_clear |= RH_PS_PESC; @@ -927,9 +924,10 @@ static struct usb_pipe *ohci_get_pipe(struct usb_dev *dev, struct usb_ep_descr * new->epno = ep->bEndpointAddress & 0xF; new->dir = ep->bEndpointAddress & 0x80; if (new->type == USB_EP_TYPE_INTR) - if (!ohci_get_pipe_intr(new, ohcd, buf, buflen)) + if (!ohci_get_pipe_intr(new, ohcd, buf, buflen)) { dprintf("usb-ohci: %s alloc_intr failed %p\n", __func__, new); + } if (new->type == USB_EP_TYPE_BULK) ohci_init_bulk_ed(dev, new); diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c index 3ce6c004fa42..d3bb88d69b9d 100644 --- a/lib/libusb/usb-xhci.c +++ b/lib/libusb/usb-xhci.c @@ -1157,7 +1157,7 @@ static inline struct xhci_seg *xhci_pipe_get_seg(struct usb_pipe *pipe) static inline void *xhci_get_trb(struct xhci_seg *seg) { uint64_t val, enq; - int index; + unsigned index; struct xhci_link_trb *link; enq = val = seg->enq; @@ -1185,7 +1185,7 @@ static inline void *xhci_get_trb(struct xhci_seg *seg) static inline void *xhci_get_trb_deq(struct xhci_seg *seg) { uint64_t deq_next, deq; - int index; + unsigned index; deq = seg->deq; deq_next = deq + XHCI_TRB_SIZE; From patchwork Wed Jan 27 08:57:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQfdq0zKmz9sS8 for ; Wed, 27 Jan 2021 21:16:31 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdp6lwRzDql0 for ; Wed, 27 Jan 2021 21:16:30 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdh1rrRzDqjY for ; Wed, 27 Jan 2021 21:16:20 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 9B559AE80278; Wed, 27 Jan 2021 03:58:11 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:44 +1100 Message-Id: <20210127085752.120571-6-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 05/13] veth: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy --- lib/libveth/veth.h | 2 +- lib/libveth/veth.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libveth/veth.h b/lib/libveth/veth.h index 23af0eab6211..6a1cb4cb5790 100644 --- a/lib/libveth/veth.h +++ b/lib/libveth/veth.h @@ -16,7 +16,7 @@ #include #include -extern net_driver_t *libveth_open(char *mac_addr, int mac_len, char *reg, int reg_len); +extern net_driver_t *libveth_open(char *mac_addr, unsigned mac_len, char *reg, unsigned reg_len); extern void libveth_close(net_driver_t *driver); extern int libveth_read(char *buf, int len, net_driver_t *driver); extern int libveth_write(char *buf, int len, net_driver_t *driver); diff --git a/lib/libveth/veth.c b/lib/libveth/veth.c index 748730854035..a8e19ba41764 100644 --- a/lib/libveth/veth.c +++ b/lib/libveth/veth.c @@ -164,7 +164,7 @@ static int veth_term(net_driver_t *driver) return 0; } -static int veth_receive(char *f_buffer_pc, int f_len_i, net_driver_t *driver) +static int veth_receive(char *f_buffer_pc, unsigned f_len_i, net_driver_t *driver) { int packet = 0; @@ -223,10 +223,14 @@ static int veth_xmit(char *f_buffer_pc, int f_len_i, net_driver_t *driver) return f_len_i; } -net_driver_t *libveth_open(char *mac_addr, int mac_len, char *reg, int reg_len) +net_driver_t *libveth_open(char *mac_addr, unsigned mac_len, char *reg, unsigned reg_len) { net_driver_t *driver; + if (reg_len != sizeof(uint32_t)) { + printf("vio reg must 1 cell long\n"); + return NULL; + } driver = SLOF_alloc_mem(sizeof(*driver)); if (!driver) { printf("Unable to allocate veth driver\n"); From patchwork Wed Jan 27 08:57:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432128 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQffG6LGtz9sWD for ; Wed, 27 Jan 2021 21:16:54 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffG4JGKzDqtr for ; Wed, 27 Jan 2021 21:16:54 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdk0ycwzDqjW for ; Wed, 27 Jan 2021 21:16:26 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 423C5AE80279; Wed, 27 Jan 2021 03:58:13 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:45 +1100 Message-Id: <20210127085752.120571-7-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 06/13] virtio: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Thomas Huth --- lib/libvirtio/p9.c | 8 ++++---- lib/libvirtio/virtio.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libvirtio/p9.c b/lib/libvirtio/p9.c index 0e595303196a..e9ba22886c06 100644 --- a/lib/libvirtio/p9.c +++ b/lib/libvirtio/p9.c @@ -142,7 +142,7 @@ void reset_buffers(void) int p9_transaction(p9_connection_t *connection) { int rc; - int tx_size = GET_SIZE; + uint32_t tx_size = GET_SIZE; uint32_t rx_size = connection->message_size; if (transact == NULL) { @@ -248,7 +248,7 @@ int p9_version(p9_connection_t *connection) int p9_attach(p9_connection_t *connection) { int rc; - int length = 19 + strlen(connection->uname) + strlen(connection->aname); + unsigned length = 19 + strlen(connection->uname) + strlen(connection->aname); if (length > connection->message_size) { return P9_MSG_TOO_LONG; @@ -372,8 +372,8 @@ int p9_walk(p9_connection_t *connection, uint32_t fid, uint32_t new_fid, s_tok = e_tok; continue; } - int tx_size = (e_tok - s_tok + 2 + GET_SIZE); - int rx_size = ((element_count + 1) * MSG_QID_SIZE + unsigned tx_size = (e_tok - s_tok + 2 + GET_SIZE); + unsigned rx_size = ((element_count + 1) * MSG_QID_SIZE + MSG_WALK_RX_HDR_SIZE); if ((tx_size > connection->message_size) || (rx_size > connection->message_size)) { diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c index 69ac4394e104..9dfc93cb2876 100644 --- a/lib/libvirtio/virtio.c +++ b/lib/libvirtio/virtio.c @@ -436,7 +436,7 @@ struct vqs *virtio_queue_init_vq(struct virtio_device *dev, unsigned int id) void virtio_queue_term_vq(struct virtio_device *dev, struct vqs *vq, unsigned int id) { if (vq->desc_gpas) { - int i; + unsigned i; for (i = 0; i < vq->size; ++i) virtio_free_desc(vq, i, dev->features); From patchwork Wed Jan 27 08:57:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQffk4mFCz9sS8 for ; Wed, 27 Jan 2021 21:17:18 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffk3RvfzDqvP for ; Wed, 27 Jan 2021 21:17:18 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQff81PjqzDqtS for ; Wed, 27 Jan 2021 21:16:47 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 831A3AE8027A; Wed, 27 Jan 2021 03:58:16 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:46 +1100 Message-Id: <20210127085752.120571-8-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 07/13] e1000: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy --- lib/libe1k/e1k.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/libe1k/e1k.c b/lib/libe1k/e1k.c index 4dd7d2eb97c2..3bbc75fba199 100644 --- a/lib/libe1k/e1k.c +++ b/lib/libe1k/e1k.c @@ -163,7 +163,7 @@ static const e1k_dev_t e1k_dev[] = { { 0x1016, E1K_82540, "82540EP Mobile" }, { 0x1017, E1K_82540, "82540EP Desktop" }, { 0x100E, E1K_82540, "82540EM Desktop" }, - { 0 , 0 } + { 0 } }; /* @@ -182,8 +182,8 @@ check_driver(uint16_t vendor_id, uint16_t device_id); static int e1k_init(net_driver_t *driver); static int e1k_term(void); -static int e1k_xmit(char *f_buffer_pc, int f_len_i); -static int e1k_receive(char *f_buffer_pc, int f_len_i); +static int e1k_xmit(char *f_buffer_pc, unsigned f_len_i); +static int e1k_receive(char *f_buffer_pc, unsigned f_len_i); /** * Translate virtual to "physical" address, ie. an address @@ -549,11 +549,11 @@ e1k_mac_init(uint8_t *f_mac_pu08) * e1k_receive */ static int -e1k_receive(char *f_buffer_pc, int f_len_i) +e1k_receive(char *f_buffer_pc, unsigned f_len_i) { uint32_t l_rdh_u32 = e1k_rd32(RDH); // this includes needed dummy read e1k_rx_desc_st *rx; - int l_ret_i; + unsigned l_ret_i; #ifdef E1K_DEBUG #ifdef E1K_SHOW_RCV_DATA @@ -589,11 +589,11 @@ e1k_receive(char *f_buffer_pc, int f_len_i) * copy the data */ memcpy((uint8_t *) f_buffer_pc, dma2virt(bswap_64(rx->m_buffer_u64)), - (size_t) l_ret_i); + (size_t) MIN(l_ret_i, f_len_i)); #ifdef E1K_DEBUG #if defined(E1K_SHOW_RCV) || defined(E1K_SHOW_RCV_DATA) - printf("e1k: %d bytes received\n", l_ret_i); + printf("e1k: %d bytes received (max %d)\n", l_ret_i, f_len_i); #endif #ifdef E1K_SHOW_RCV_DATA @@ -631,7 +631,7 @@ e1k_receive(char *f_buffer_pc, int f_len_i) } static int -e1k_xmit(char *f_buffer_pc, int f_len_i) +e1k_xmit(char *f_buffer_pc, unsigned f_len_i) { uint32_t l_tdh_u32 = e1k_rd32(TDH); uint32_t l_tdt_u32 = e1k_rd32(TDT); From patchwork Wed Jan 27 08:57:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432129 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQffM6Tqfz9sS8 for ; Wed, 27 Jan 2021 21:16:59 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffM42QczDqkX for ; Wed, 27 Jan 2021 21:16:59 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdk2yYXzDqjY for ; Wed, 27 Jan 2021 21:16:26 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id CA5DDAE8027B; Wed, 27 Jan 2021 03:58:18 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:47 +1100 Message-Id: <20210127085752.120571-9-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 08/13] libnet: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy --- lib/libnet/netapps.h | 4 ++-- lib/libnet/netload.c | 4 ++-- lib/libnet/ping.c | 6 +++--- lib/libnet/pxelinux.c | 5 +++-- slof/ppc64.c | 12 +++++++++--- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/libnet/netapps.h b/lib/libnet/netapps.h index 6e00466de5a9..722ca7ff7ab4 100644 --- a/lib/libnet/netapps.h +++ b/lib/libnet/netapps.h @@ -18,8 +18,8 @@ struct filename_ip; -extern int netload(char *buffer, int len, char *args_fs, int alen); -extern int ping(char *args_fs, int alen); +extern int netload(char *buffer, int len, char *args_fs, unsigned alen); +extern int ping(char *args_fs, unsigned alen); extern int dhcp(char *ret_buffer, struct filename_ip *fn_ip, unsigned int retries, int flags); diff --git a/lib/libnet/netload.c b/lib/libnet/netload.c index 2dc00f00097d..ae169f3e015d 100644 --- a/lib/libnet/netload.c +++ b/lib/libnet/netload.c @@ -528,7 +528,7 @@ static void encode_response(char *pkt_buffer, size_t size, int ip_init) } } -int netload(char *buffer, int len, char *args_fs, int alen) +int netload(char *buffer, int len, char *args_fs, unsigned alen) { int rc, filename_len; filename_ip_t fn_ip; @@ -566,7 +566,7 @@ int netload(char *buffer, int len, char *args_fs, int alen) set_timer(TICKS_SEC); while (get_timer() > 0); } - fd_device = socket(0, 0, 0, (char*) own_mac); + fd_device = socket(AF_INET, SOCK_DGRAM, 0, (char*) own_mac); if(fd_device != -2) break; if(getchar() == 27) { diff --git a/lib/libnet/ping.c b/lib/libnet/ping.c index 51db061ecaff..476c4fe44ba7 100644 --- a/lib/libnet/ping.c +++ b/lib/libnet/ping.c @@ -106,7 +106,7 @@ parse_args(const char *args, struct ping_args *ping_args) return 0; } -int ping(char *args_fs, int alen) +int ping(char *args_fs, unsigned alen) { short arp_failed = 0; filename_ip_t fn_ip; @@ -119,7 +119,7 @@ int ping(char *args_fs, int alen) memset(&ping_args, 0, sizeof(struct ping_args)); - if (alen <= 0 || alen >= sizeof(args) - 1) { + if (alen >= sizeof(args) - 1) { usage(); return -1; } @@ -137,7 +137,7 @@ int ping(char *args_fs, int alen) /* Get mac_addr from device */ printf("\n Reading MAC address from device: "); - fd_device = socket(0, 0, 0, (char *) own_mac); + fd_device = socket(AF_INET, SOCK_DGRAM, 0, (char *) own_mac); if (fd_device == -1) { printf("\nE3000: Could not read MAC address\n"); return -100; diff --git a/lib/libnet/pxelinux.c b/lib/libnet/pxelinux.c index c4ac5d5a078a..be1939f24d8b 100644 --- a/lib/libnet/pxelinux.c +++ b/lib/libnet/pxelinux.c @@ -55,7 +55,8 @@ static int pxelinux_tftp_load(filename_ip_t *fnip, void *buffer, int len, static int pxelinux_load_cfg(filename_ip_t *fn_ip, uint8_t *mac, const char *uuid, int retries, char *cfgbuf, int cfgbufsize) { - int rc, idx; + int rc; + unsigned idx; char *baseptr; /* Did we get a usable base directory via DHCP? */ @@ -77,7 +78,7 @@ static int pxelinux_load_cfg(filename_ip_t *fn_ip, uint8_t *mac, const char *uui ++baseptr; /* Check that we've got enough space to store "pxelinux.cfg/" * and the UUID (which is the longest file name) there */ - if (baseptr - fn_ip->filename > sizeof(fn_ip->filename) - 50) { + if (baseptr - fn_ip->filename > (int)(sizeof(fn_ip->filename) - 50)) { puts("Error: The bootfile string is too long for " "deriving the pxelinux.cfg file name from it."); return -1; diff --git a/slof/ppc64.c b/slof/ppc64.c index 83a8e82cfb42..ca6cafffc35d 100644 --- a/slof/ppc64.c +++ b/slof/ppc64.c @@ -144,6 +144,12 @@ int socket(int domain, int type, int proto, char *mac_addr) int prop_len; int fd; + if (!(domain == AF_INET || domain == AF_INET6)) + return -1; + + if (type != SOCK_DGRAM || proto != 0) + return -1; + /* search free file descriptor (and skip stdio handlers) */ for (fd = 3; fd < FILEIO_MAX; ++fd) { if (fd_array[fd].type == FILEIO_TYPE_EMPTY) { @@ -217,7 +223,7 @@ int close(int fd) */ int recv(int fd, void *buf, int len, int flags) { - if (!is_valid_fd(fd)) + if (!is_valid_fd(fd) || flags) return -1; forth_push((unsigned long)buf); @@ -237,7 +243,7 @@ int recv(int fd, void *buf, int len, int flags) */ int send(int fd, const void *buf, int len, int flags) { - if (!is_valid_fd(fd)) + if (!is_valid_fd(fd) || flags) return -1; forth_push((unsigned long)buf); @@ -258,7 +264,7 @@ int send(int fd, const void *buf, int len, int flags) ssize_t read(int fd, void *buf, size_t len) { char *ptr = (char *)buf; - int cnt = 0; + unsigned cnt = 0; char code; if (fd == 0 || fd == 2) { From patchwork Wed Jan 27 08:57:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQffZ2PGyz9sS8 for ; Wed, 27 Jan 2021 21:17:10 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffZ1WC2zDqjp for ; Wed, 27 Jan 2021 21:17:10 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdk70BJzDqjY for ; Wed, 27 Jan 2021 21:16:26 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id E15D8AE8027C; Wed, 27 Jan 2021 03:58:20 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:48 +1100 Message-Id: <20210127085752.120571-10-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 09/13] libhv: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Thomas Huth --- include/ppcp7/cache.h | 2 +- lib/libhvcall/rfill.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ppcp7/cache.h b/include/ppcp7/cache.h index 3c02bb10de63..611b6a33599e 100644 --- a/include/ppcp7/cache.h +++ b/include/ppcp7/cache.h @@ -124,7 +124,7 @@ static inline void ci_rmove(void *dst, void *src, unsigned long esize, #define FAST_MRMOVE(s, d, size) _FASTRMOVE(s, d, size) -extern void fast_rfill(char *dst, long size, char pat); +extern void fast_rfill(char *dst, unsigned long size, char pat); #define FAST_RFILL(dst, size, pat) fast_rfill(dst, size, pat) static inline uint16_t bswap16_load(uint64_t addr) diff --git a/lib/libhvcall/rfill.c b/lib/libhvcall/rfill.c index 5407cd2a60e7..377fb892ba60 100644 --- a/lib/libhvcall/rfill.c +++ b/lib/libhvcall/rfill.c @@ -23,7 +23,7 @@ typedef unsigned long type_u; * local buffer - and that caused stack size problems in engine() when * we used it directly in the FAST_RFILL macro. */ -void fast_rfill(char *dst, long size, char pat) +void fast_rfill(char *dst, unsigned long size, char pat) { type_u buf[64]; From patchwork Wed Jan 27 08:57:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432134 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQffp4TJlz9sWD for ; Wed, 27 Jan 2021 21:17:22 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffp3RW3zDql0 for ; Wed, 27 Jan 2021 21:17:22 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffJ12v7zDqlw for ; Wed, 27 Jan 2021 21:16:55 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 2C5D5AE8027D; Wed, 27 Jan 2021 03:58:22 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:49 +1100 Message-Id: <20210127085752.120571-11-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 10/13] libnvram: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy --- lib/libnvram/nvram.h | 10 +++++----- lib/libnvram/envvar.c | 13 ++++++------- lib/libnvram/nvram.c | 13 ++++++------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/libnvram/nvram.h b/lib/libnvram/nvram.h index 73fe44424400..c8aad3151d96 100644 --- a/lib/libnvram/nvram.h +++ b/lib/libnvram/nvram.h @@ -47,7 +47,7 @@ nvram_access_proto(uint64_t, qword) /* nvram.c */ -char *get_nvram_buffer(int len); +char *get_nvram_buffer(unsigned len); void free_nvram_buffer(char *buffer); int nvramlog_printf(const char* fmt, ...); partition_t get_partition(unsigned int type, char *name); @@ -67,9 +67,9 @@ void nvram_init(uint32_t store_token, uint32_t fetch_token, unsigned int get_nvram_size(void); /* envvar.c */ -char *nvram_get_env(partition_t part, char *envvar, int evlen); -int nvram_add_env(partition_t part, char *envvar, int evlen, char *value, int vallen); -int nvram_del_env(partition_t part, char *envvar, int evlen); -int nvram_set_env(partition_t part, char *envvar, int evlen, char *val, int vlen); +char *nvram_get_env(partition_t part, char *envvar, unsigned evlen); +int nvram_add_env(partition_t part, char *envvar, unsigned evlen, char *value, unsigned vallen); +int nvram_del_env(partition_t part, char *envvar, unsigned evlen); +int nvram_set_env(partition_t part, char *envvar, unsigned evlen, char *val, unsigned vlen); #endif diff --git a/lib/libnvram/envvar.c b/lib/libnvram/envvar.c index ee943fce5127..d413e9750d77 100644 --- a/lib/libnvram/envvar.c +++ b/lib/libnvram/envvar.c @@ -46,7 +46,7 @@ static int get_past_env_pos(partition_t part, char *envvar, int evlen) * @param evlen string length of the envvar parameter * @return pointer to temporary string containing the value of envvar */ -char *nvram_get_env(partition_t part, char *envvar, int evlen) +char *nvram_get_env(partition_t part, char *envvar, unsigned evlen) { static char temp[256+1]; int len, offset; @@ -100,10 +100,9 @@ static int find_last_envvar(partition_t part) return -1; } -int nvram_add_env(partition_t part, char *envvar, int evlen, char *value, int vallen) +int nvram_add_env(partition_t part, char *envvar, unsigned evlen, char *value, unsigned vallen) { - int freespace, last, len, offset; - unsigned int i; + unsigned i, freespace, last, len, offset; /* Find offset where we can write */ last = find_last_envvar(part); @@ -132,7 +131,7 @@ int nvram_add_env(partition_t part, char *envvar, int evlen, char *value, int va return 0; } -int nvram_del_env(partition_t part, char *envvar, int evlen) +int nvram_del_env(partition_t part, char *envvar, unsigned evlen) { int last, current, pos, i; char *buffer; @@ -168,10 +167,10 @@ int nvram_del_env(partition_t part, char *envvar, int evlen) return 0; } -int nvram_set_env(partition_t part, char *envvar, int evlen, char *value, int vallen) +int nvram_set_env(partition_t part, char *envvar, unsigned evlen, char *value, unsigned vallen) { char *oldvalue, *buffer; - int last, current, buffersize, i; + unsigned last, current, buffersize, i; DEBUG("nvram_set_env %lx[%lx]: %p=>%p\n", part.addr, part.len, envvar, value); diff --git a/lib/libnvram/nvram.c b/lib/libnvram/nvram.c index 99deb2a8f7e4..6d145d79e86c 100644 --- a/lib/libnvram/nvram.c +++ b/lib/libnvram/nvram.c @@ -163,7 +163,7 @@ nvram_access(uint64_t, 64, qword) * @return pointer to temporary buffer */ -char *get_nvram_buffer(int len) +char *get_nvram_buffer(unsigned len) { if(len>NVRAM_LENGTH) return NULL; @@ -271,7 +271,7 @@ static uint8_t calc_partition_header_checksum(int offset) static int calc_used_nvram_space(void) { - int walk, len; + unsigned walk, len; for (walk=0; walk X-Patchwork-Id: 1432127 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQff95xrqz9sS8 for ; Wed, 27 Jan 2021 21:16:49 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQff95FT6zDqkX for ; Wed, 27 Jan 2021 21:16:49 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdj4RWLzDqjW for ; Wed, 27 Jan 2021 21:16:25 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 39984AE8027E; Wed, 27 Jan 2021 03:58:24 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:50 +1100 Message-Id: <20210127085752.120571-12-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 11/13] libtpm: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy --- lib/libtpm/tcgbios.c | 8 ++++---- lib/libtpm/tpm_drivers.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c index 8e808115bc59..6baa5b44a8e6 100644 --- a/lib/libtpm/tcgbios.c +++ b/lib/libtpm/tcgbios.c @@ -356,7 +356,7 @@ tpm_simple_cmd(uint8_t locty, uint32_t ordinal, int param_size, uint16_t param, memset(obuffer, 0, sizeof(obuffer)); ret = spapr_transmit(locty, &req.trqh, obuffer, &obuffer_len, to_t); - ret = ret ? -1 : be32_to_cpu(trsh->errcode); + ret = ret ? -1 : (int) be32_to_cpu(trsh->errcode); dprintf("Return from tpm_simple_cmd(%x, %x) = %x\n", ordinal, param, ret); @@ -382,7 +382,7 @@ tpm20_getcapability(uint32_t capability, uint32_t property, uint32_t count, TPM_DURATION_TYPE_SHORT); ret = (ret || rsize < be32_to_cpu(rsp->totlen)) ? -1 - : be32_to_cpu(rsp->errcode); + : (int) be32_to_cpu(rsp->errcode); dprintf("TCGBIOS: Return value from sending TPM2_CC_GetCapability = 0x%08x\n", ret); @@ -664,7 +664,7 @@ static int tpm20_write_EfiSpecIdEventStruct(void) }; struct tpms_pcr_selection *sel; void *nsel, *end; - int event_size; + unsigned event_size; uint8_t *vendorInfoSize; struct tpm_log_entry le = { .hdr.eventtype = cpu_to_log32(EV_NO_ACTION), @@ -1252,7 +1252,7 @@ tpm20_set_pcrbanks(uint32_t active_banks) ret = spapr_transmit(0, &trpa.hdr, &rsp, &resp_length, TPM_DURATION_TYPE_SHORT); - ret = ret ? -1 : be32_to_cpu(rsp.errcode); + ret = ret ? -1 : (int) be32_to_cpu(rsp.errcode); return ret; } diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c index 0e13561d0fa0..85cb3098712d 100644 --- a/lib/libtpm/tpm_drivers.c +++ b/lib/libtpm/tpm_drivers.c @@ -357,8 +357,7 @@ static bool spapr_vtpm_senddata(const uint8_t *const data, uint32_t len) static bool spapr_vtpm_waitresponseready(enum tpm_duration_type to_t) { - uint32_t timeout = tpm2_durations[to_t]; - int i; + uint32_t i, timeout = tpm2_durations[to_t]; if (vtpm_drv_error_get() != VTPM_DRV_ERROR_NO_FAILURE) { printf("%s: VTPM CRQ: In failure mode\n", __func__); @@ -426,6 +425,8 @@ int spapr_transmit(uint8_t locty, struct tpm_req_header *req, void *respbuffer, uint32_t *respbufferlen, enum tpm_duration_type to_t) { + if (locty) + return -1; if (!spapr_vtpm_senddata((uint8_t *)req, be32_to_cpu(req->totlen)) || !spapr_vtpm_waitresponseready(to_t) || !spapr_vtpm_readresponse(respbuffer, respbufferlen) || From patchwork Wed Jan 27 08:57:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQfg61rlxz9sS8 for ; Wed, 27 Jan 2021 21:17:38 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfg54DKjzDqjY for ; Wed, 27 Jan 2021 21:17:37 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQffK0JvqzDqqD for ; Wed, 27 Jan 2021 21:16:56 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 434C0AE8027F; Wed, 27 Jan 2021 03:58:26 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:51 +1100 Message-Id: <20210127085752.120571-13-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 12/13] slof/prim: Compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy --- slof/prim.code | 3 +++ 1 file changed, 3 insertions(+) diff --git a/slof/prim.code b/slof/prim.code index bb9e036a9933..b9db1519cbcb 100644 --- a/slof/prim.code +++ b/slof/prim.code @@ -469,18 +469,21 @@ code_FILL: #endif while ((size-=sizeof(type_u)) >= 0) *up++ = fill_v; + break; } case sizeof(type_l): { type_l *lp = (type_l *)d; while ((size-=sizeof(type_l)) >= 0) *lp++ = (type_l)fill_v; + break; } case sizeof(type_w): { type_w *wp = (type_w *)d; while ((size-=sizeof(type_w)) >= 0) *wp++ = (type_w)fill_v; + break; } default: while (size-- > 0) From patchwork Wed Jan 27 08:57:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1432125 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQfdz5925z9sS8 for ; Wed, 27 Jan 2021 21:16:39 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdz0vkpzDqvN for ; Wed, 27 Jan 2021 21:16:39 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) X-Greylist: delayed 4698 seconds by postgrey-1.36 at bilbo; Wed, 27 Jan 2021 21:16:24 AEDT Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQfdh1DWszDqjW for ; Wed, 27 Jan 2021 21:16:20 +1100 (AEDT) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 82A30AE80281; Wed, 27 Jan 2021 03:58:29 -0500 (EST) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Wed, 27 Jan 2021 19:57:52 +1100 Message-Id: <20210127085752.120571-14-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210127085752.120571-1-aik@ozlabs.ru> References: <20210127085752.120571-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 13/13] Makefile: Actually compile with -Wextra X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" -Wextra enables a bunch of rather useful checks which this fixes. The only exception is -Wno-unused-parameter, one thing at the time. Signed-off-by: Alexey Kardashevskiy --- make.rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.rules b/make.rules index 3dfbb5b136c2..885eea3f48b0 100644 --- a/make.rules +++ b/make.rules @@ -76,7 +76,7 @@ AR ?= $(CROSS)ar RANLIB ?= $(CROSS)ranlib CPP ?= $(CROSS)cpp -WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security +WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \ -fno-strict-aliasing -mno-altivec -mabi=no-altivec \ -fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS)