From 82b276a34c9492ffb7137d616db02f9e120ea2d8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Mar 2019 10:09:03 -0600 Subject: [PATCH] binfmt/nxflat.c: Trivial design simplification. --- arch/arm/src/stm32f7/stm32_ethernet.c | 4 +-- binfmt/nxflat.c | 37 ++++++++++++--------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/arch/arm/src/stm32f7/stm32_ethernet.c b/arch/arm/src/stm32f7/stm32_ethernet.c index 8bc11ffe20..7a879724b5 100644 --- a/arch/arm/src/stm32f7/stm32_ethernet.c +++ b/arch/arm/src/stm32f7/stm32_ethernet.c @@ -2675,11 +2675,11 @@ static int stm32_addmac(struct net_driver_s *dev, const uint8_t *mac) registeraddress = STM32_ETH_MACHTLR; } - temp = stm32_getreg(registeraddress); + temp = stm32_getreg(registeraddress); temp |= 1 << hashindex; stm32_putreg(temp, registeraddress); - temp = stm32_getreg(STM32_ETH_MACFFR); + temp = stm32_getreg(STM32_ETH_MACFFR); temp |= (ETH_MACFFR_HM | ETH_MACFFR_HPF); stm32_putreg(temp, STM32_ETH_MACFFR); diff --git a/binfmt/nxflat.c b/binfmt/nxflat.c index ee82f96561..2e729a7581 100644 --- a/binfmt/nxflat.c +++ b/binfmt/nxflat.c @@ -244,28 +244,25 @@ static int nxflat_unloadbinary(FAR struct binary_s *binp) { FAR struct dspace_s *dspace = (FAR struct dspace_s *)binp->alloc[0]; - if (dspace != NULL) + /* Check if this is the last reference to dspace. It may still be needed + * by other threads. In that case, it must persist after this thread + * terminates. + */ + + if (dspace != NULL && dspace->crefs == 1) { - /* Check if this is the last reference to dspace. It may still be - * needed by other threads. In that case, it must persist after this - * thread terminates. + /* Free the dspace region */ + + kumm_free(dspace->region); + dspace->region = NULL; + + /* Mark alloc[0] (dspace) as freed */ + + binp->alloc[0] = NULL; + + /* The reference count will be decremented to zero and the dspace + * container will be freed in sched/sched_releasetcb.c */ - - if (dspace->crefs == 1) - { - /* Free the dspace region */ - - kumm_free(dspace->region); - dspace->region = NULL; - - /* Mark alloc[0] (dspace) as freed */ - - binp->alloc[0] = NULL; - - /* The reference count will be decremented to zero and the dspace - * container will be freed in sched/sched_releasetcb.c - */ - } } return OK;