poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/7] ios: Pass offset to low-level macros.


From: Egeyar Bagcioglu
Subject: Re: [PATCH 2/7] ios: Pass offset to low-level macros.
Date: Sat, 29 Feb 2020 16:30:22 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

I have just sent the following to only Eric and not to the mailing list by mistake.

Regards
Egeyar

On 2/29/20 4:22 PM, Egeyar Bagcioglu wrote:
Hi Eric,

+++ b/src/ios.c
@@ -32,7 +32,7 @@

  #define STREQ(a, b) (strcmp (a, b) == 0)

-#define IOS_GET_C_ERR_CHCK(c, io)               \
+#define IOS_GET_C_ERR_CHCK(c, io, off)        \
    {                                             \
    int ret = io->dev_if->get_c ((io)->dev);     \

Just noticing: We're inconsistent on whether the 'io' argument to this macro is allowed to be an arbitrary expression. Fortunately, none of the callers pass a complex expression, but the correct spelling for arbitrary syntax would be:

int ret = (io)->dev_if->get_c ((io)->dev); \

yet that still would result in multiple side effects; so even more reusable would be:

ios io_ = (io); \
int ret = io_->dev_if->get_c (io_->dev); \

Or, we can declare that this macro is not intended to be reusable outside this file, and could spell it:

int ret = io->dev_if->get_c (io->dev); \

or go one step further and declare that it is only to be run inside a function where 'io' is already in scope, and not pass in an io argument to the macro.

I'd go with this one if I wanted to fix that. But really, they all seem fine to me. Your call.


I don't have any strong preferences, but am happy to tweak this and subsequent patches to match any style that someone expresses a preference for.


Thanks
Egeyar




reply via email to

[Prev in Thread] Current Thread [Next in Thread]