Skip to contentSkip to conversation

service: Const-qualify 'connman_service_get_interface'.

PATCH In review Grant Erickson 2 participants 2 messages Nov 17, 2023 – Nov 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 service: Const-qualify 'connman_service_get_interface'.

Const-qualify the network service argument to make it clear to the compiler, static analyzers, and human readers that the function is strictly a getter with no network service mutation side effects.

---
 include/service.h     | 2 +-
 src/service.c         | 2 +-
 tools/iptables-unit.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
include/service.h +1 -1
index e45d7b58da7d..69f93574bafb 100644
@@ -116,7 +116,7 @@ void connman_service_unref_debug(struct connman_service *service,
 
 enum connman_service_type connman_service_get_type(const struct connman_service *service);
 enum connman_service_state connman_service_get_state(const struct connman_service *service);
-char *connman_service_get_interface(struct connman_service *service);
+char *connman_service_get_interface(const struct connman_service *service);
 
 const char *connman_service_get_identifier(const struct connman_service *service);
 const char *connman_service_get_domainname(const struct connman_service *service);
src/service.c +1 -1
index 81a1bebdc14b..a94d14652eb2 100644
@@ -6196,7 +6196,7 @@ enum connman_service_type connman_service_get_type(const struct connman_service
  *
  * Get network interface of service
  */
-char *connman_service_get_interface(struct connman_service *service)
+char *connman_service_get_interface(const struct connman_service *service)
 {
 	int index;
 
tools/iptables-unit.c +1 -1
index b91591f23e7f..d490b87d80ca 100644
@@ -624,7 +624,7 @@ struct connman_service {
 	char *dummy;
 };
 
-char *connman_service_get_interface(struct connman_service *service)
+char *connman_service_get_interface(const struct connman_service *service)
 {
 	return "eth0";
 }
Signature · 1 line
2.42.0
#1 lore raw

Hi Grant,

Quoted 8 lines

Const-qualify the network service argument to make it clear to the compiler, static analyzers, and human readers that the function is strictly a getter with no network service mutation side effects.
---

include/service.h     | 2 +-
src/service.c         | 2 +-
tools/iptables-unit.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

patch has been applied.

Regards

Marcel