From: Nathael Pajani Date: Sun, 27 Jul 2014 23:24:07 +0000 (+0200) Subject: Make sure we receive valid (at least not NULL) pointers Add a few comments X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=cc25cd1981356645f601ad8c591c35cf201ec83c;p=soft%2Flpc122x%2Fcore Make sure we receive valid (at least not NULL) pointers Add a few comments --- diff --git a/core/pio.c b/core/pio.c index b2afd9f..d1cb89d 100644 --- a/core/pio.c +++ b/core/pio.c @@ -95,17 +95,25 @@ static volatile uint32_t* pio_regs_handles_port2[PORT2_NB_PINS] = { &(LPC_IO_CONTROL->pio2_15), }; +/* Simple copy function. */ void pio_copy(struct pio* dst, struct pio* src) { + if ((dst == NULL) || (src == NULL)) { + return; + } dst->port = src->port; dst->pin = src->pin; dst->alt_setting = src->alt_setting; } +/* Configure the pin in the requested function and mode. */ void config_pio(struct pio* pp, uint32_t mode) { volatile uint32_t* handle = NULL; + if (pp == NULL) { + return; + } switch (pp->port) { case 0: if (pp->pin >= PORT0_NB_PINS) diff --git a/include/core/pio.h b/include/core/pio.h index 223189d..97daffc 100644 --- a/include/core/pio.h +++ b/include/core/pio.h @@ -36,8 +36,10 @@ struct pio { #define PORT1_NB_PINS 7 #define PORT2_NB_PINS 16 +/* Simple copy function. */ void pio_copy(struct pio* dst, struct pio* src); +/* Configure the pin in the requested function and mode. */ void config_pio(struct pio* pp, uint32_t mode);