Skip to content

make: fix unused-params error#7995

Merged
miri64 merged 1 commit intoRIOT-OS:masterfrom
smlng:make/fix/unused_params
Nov 28, 2017
Merged

make: fix unused-params error#7995
miri64 merged 1 commit intoRIOT-OS:masterfrom
smlng:make/fix/unused_params

Conversation

@smlng
Copy link
Copy Markdown
Member

@smlng smlng commented Nov 10, 2017

This RP is required to achieve #7919, it fixes several unused-params errors.

@smlng smlng added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Area: build system Area: Build system labels Nov 10, 2017
@smlng smlng added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 10, 2017
cladmi
cladmi previously approved these changes Nov 10, 2017
Copy link
Copy Markdown
Contributor

@cladmi cladmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, murdock still builds correctly, ACK.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 10, 2017

@cladmi if you haven't already: please do not merge

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 10, 2017

according to #7919 there are lots more of these to fix, I'll try to append

@smlng smlng added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Nov 10, 2017
@smlng smlng changed the title make: fix unused-params error [WIP] make: fix unused-params error Nov 10, 2017
@smlng smlng force-pushed the make/fix/unused_params branch from 0e29aa8 to ee2f085 Compare November 10, 2017 15:24
@miri64 miri64 dismissed cladmi’s stale review November 11, 2017 22:40

Dismissed because of changes after ACK

@smlng smlng changed the title [WIP] make: fix unused-params error make: fix unused-params error Nov 11, 2017
@smlng smlng removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Nov 11, 2017
assert(dev < I2C_NUMOF);
mutex_lock(&lock);
return 0;
if (dev < I2C_NUMOF) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: I think there is a reason why the author chose assert() over if (). Better use (void) dev instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be the general consent that if () should be used instead of assert(), at least most platforms do, accept this and the nrf51. Maybe someone more into periph can give there opinion here, @gebart or @haukepetersen?

But if the change-over to if () should happen I would rather like to see it in a separate PR and also for nrf51 as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason for that is, that the API requires to return an error for invalid device, so an assert is just not enough here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall I also factor this one out into a separate PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer that.

#ifdef DXL_DIR_PIN
static void dir_init(uart_t uart) {
static void dir_init(uart_t uart)
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: unrelated style fixes, but okay.

PMC->PMC_PCER1 = (1 << (ID_DACC - 32));
DACC->DACC_CHER = PMC_BIT;
DACC->DACC_CHER = (1 << line);
PMC->PMC_PCER1 = PMC_BIT;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhhhh this changes the functionality. From the surrounding lines I suspect this is correct, but I'm not sure. @haukepetersen can you confirm, please?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make the review easier if this was a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay I'll factor out.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 13, 2017

requires #8013

@smlng smlng added the State: waiting for other PR State: The PR requires another PR to be merged first label Nov 13, 2017
@kaspar030 kaspar030 added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Nov 13, 2017
@smlng smlng force-pushed the make/fix/unused_params branch 2 times, most recently from f791688 to 6af87dc Compare November 13, 2017 12:27
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 13, 2017

requires #8017

cladmi
cladmi previously requested changes Nov 14, 2017
Copy link
Copy Markdown
Contributor

@cladmi cladmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all cases where a parameter is only used when assert is enabled, you can enclose them with #ifdef NDEBUG.
I tried listing them all (sorry for the repeated boring copy-pasted message).

Either than that, it looks good and trust murdock.

void i2c_poweron(i2c_t dev)
{
assert(dev < I2C_NUMOF);
(void) dev;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) dev; with #ifdef NDEBUG

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this will decrease readability and the compiler with optimise out one or the other anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @smlng. This would lead to very ugly code.

void i2c_poweroff(i2c_t dev)
{
assert(dev < I2C_NUMOF);
(void) dev;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) dev; with #ifdef NDEBUG


void eic_irq_configure(int irq_num)
{
(void)irq_num;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) irq_num with #ifdef NDEBUG


void eic_irq_enable(int irq_num)
{
(void)irq_num;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) irq_num with #ifdef NDEBUG


void eic_irq_disable(int irq_num)
{
(void)irq_num;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) irq_num with #ifdef NDEBUG


uint8_t pwm_channels(pwm_t pwm)
{
(void)pwm;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) pwm with #ifdef NDEBUG

*/
void pwm_set(pwm_t pwm, uint8_t channel, uint16_t value)
{
(void)pwm;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) pwm with #ifdef NDEBUG


void pwm_poweron(pwm_t pwm)
{
(void)pwm;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) pwm with #ifdef NDEBUG


void pwm_poweroff(pwm_t pwm)
{
(void)pwm;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void) pwm with #ifdef NDEBUG


static int _get_iid(netdev_ieee802154_t *dev, eui64_t *value, size_t max_len)
{
(void)max_len;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could enclose the (void)max_len with #ifdef NDEBUG

@cladmi cladmi dismissed their stale review November 14, 2017 17:46

Choosen that no need to enclose the (void)var with #ifdef NDEBUG when only used by assert.

@smlng smlng force-pushed the make/fix/unused_params branch from 6af87dc to 3bc3b96 Compare November 28, 2017 09:42
@smlng smlng removed the State: waiting for other PR State: The PR requires another PR to be merged first label Nov 28, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 28, 2017

rebased, may I squash?

@smlng smlng added the Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties label Nov 28, 2017
Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@miri64
Copy link
Copy Markdown
Member

miri64 commented Nov 28, 2017

(yes, please squash)

        cpu, sam0_common: fix unused parameter in periph/spi
        cpu, kinetis_common: fix unused parameter in periph/spi
        cpu, cc2538: fix unused param in periph/i2c
        cpu, cc2538: fix unused param in periph/spi
        cpu, sam3: fix unused param in periph/spi
        cpu, stm32_common: fix unused param in periph/pm
        cpu, stm32f3: fix unused params in periph/i2c
        cpu, nrf5x_common: fix unused param in periph/gpio
        cpu, nrf5x_common: fix unused param in periph/spi
        cpu, lpc2387: fix unused params in periph/spi
        cpu, cc2538: fix unused params in radio/netdev
        cpu, cc2650: fix unused params in periph/uart
        cpu, lm4f120: fix unused param in periph/spi
        cpu, lm4f120: fix unused params in periph/timer
        cpu, lm4f120: fix unused params in periph/uart
        cpu, stm32_common: fix unused params in periph/dac
        cpu, stm32l0: fix unused params in periph/i2c
        cpu, msp430fxyz: fix unused params in periph/uart
        cpu, mips: fix unused params
        cpu, cc430: fix unused-params in periph/timer
        cpu, msp430fxyz: fix unused params in periph/spi
        drivers, cc2420: fix unused param
        cpu, mips32r2_common: fix unused params in periph/timer
        cpu, cc2538: fix unused-param in periph/i2c
        cpu, mips32r2_common: fix unused-param in periph/timer
        cpu, msp430fxyz: fix unused params in periph/timer
        cpu, atmega_common: fix unused params in periph/spi
        driver, nrfmin: fix unused params
        cpu, cc2538_rf: fix unused params
        driver, netdev_ieee802514: fix unused param
        cpu, mip_pic32m: fix unused params
        cpu, lpc2387: fix unused params in periph/pwm
        tests/driver_sdcard_spi: fix unused params
        cpu, sam3: fix unused param in periph/pwm
        tests/driver_dynamixel: fix unused params, and style issues
        cpu, cc430: fix unused param in periph/rtc
        cpu, atmega_common: fix unused params in periph/i2c
@smlng smlng force-pushed the make/fix/unused_params branch from 3bc3b96 to 7309171 Compare November 28, 2017 13:38
@smlng smlng added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 28, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Nov 28, 2017

squashed

@miri64 miri64 merged commit 39c1221 into RIOT-OS:master Nov 28, 2017
@smlng smlng deleted the make/fix/unused_params branch November 28, 2017 13:48
@aabadie aabadie added this to the Release 2018.01 milestone Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants