[4/5] resolv: don't pass struct ns_mst by value
diff mbox series

Message ID 20190324122121.6430-5-Hi-Angel@yandex.ru
State New
Headers show
Series
  • Minor LGTM fixes
Related show

Commit Message

Konstantin Kharlamov March 24, 2019, 12:21 p.m. UTC
Fixes LGTM warning: "This parameter of type ns_msg is 80 bytes -
consider passing a const pointer/reference instead."

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
---
 resolv/arpa/nameser.h | 2 +-
 resolv/ns_parse.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Florian Weimer March 25, 2019, 8:25 a.m. UTC | #1
* Konstantin Kharlamov:

> Fixes LGTM warning: "This parameter of type ns_msg is 80 bytes -
> consider passing a const pointer/reference instead."
>
> Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> ---
>  resolv/arpa/nameser.h | 2 +-
>  resolv/ns_parse.c     | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/resolv/arpa/nameser.h b/resolv/arpa/nameser.h
> index a99d5ec508..7d2f717848 100644
> --- a/resolv/arpa/nameser.h
> +++ b/resolv/arpa/nameser.h
> @@ -390,7 +390,7 @@ typedef enum __ns_cert_types {
>  } while (0)
>  
>  __BEGIN_DECLS
> -int		ns_msg_getflag (ns_msg, int) __THROW;
> +int		ns_msg_getflag (const ns_msg*, int) __THROW;

Surely that's not right because this is an installed header, so it
would break ABI.
Konstantin Kharlamov March 27, 2019, 8:45 a.m. UTC | #2
Np, let's drop this patch.

On Пн, Mar 25, 2019 at 09:25, Florian Weimer <fw@deneb.enyo.de> wrote:
> * Konstantin Kharlamov:
> 
>>  Fixes LGTM warning: "This parameter of type ns_msg is 80 bytes -
>>  consider passing a const pointer/reference instead."
>> 
>>  Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
>>  ---
>>   resolv/arpa/nameser.h | 2 +-
>>   resolv/ns_parse.c     | 4 ++--
>>   2 files changed, 3 insertions(+), 3 deletions(-)
>> 
>>  diff --git a/resolv/arpa/nameser.h b/resolv/arpa/nameser.h
>>  index a99d5ec508..7d2f717848 100644
>>  --- a/resolv/arpa/nameser.h
>>  +++ b/resolv/arpa/nameser.h
>>  @@ -390,7 +390,7 @@ typedef enum __ns_cert_types {
>>   } while (0)
>> 
>>   __BEGIN_DECLS
>>  -int		ns_msg_getflag (ns_msg, int) __THROW;
>>  +int		ns_msg_getflag (const ns_msg*, int) __THROW;
> 
> Surely that's not right because this is an installed header, so it
> would break ABI.

Patch
diff mbox series

diff --git a/resolv/arpa/nameser.h b/resolv/arpa/nameser.h
index a99d5ec508..7d2f717848 100644
--- a/resolv/arpa/nameser.h
+++ b/resolv/arpa/nameser.h
@@ -390,7 +390,7 @@  typedef enum __ns_cert_types {
 } while (0)
 
 __BEGIN_DECLS
-int		ns_msg_getflag (ns_msg, int) __THROW;
+int		ns_msg_getflag (const ns_msg*, int) __THROW;
 unsigned int	ns_get16 (const unsigned char *) __THROW;
 unsigned long	ns_get32 (const unsigned char *) __THROW;
 void		ns_put16 (unsigned int, unsigned char *) __THROW;
diff --git a/resolv/ns_parse.c b/resolv/ns_parse.c
index 863b20a9f7..5211bcdd49 100644
--- a/resolv/ns_parse.c
+++ b/resolv/ns_parse.c
@@ -57,8 +57,8 @@  const struct _ns_flagdata _ns_flagdata[16] = {
 };
 
 #undef ns_msg_getflag
-int ns_msg_getflag(ns_msg handle, int flag) {
-	return(((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift);
+int ns_msg_getflag(const ns_msg *handle, int flag) {
+	return(((handle)->_flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift);
 }
 
 int