You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/11/08 18:25:04 UTC

[GitHub] andrzej-kaczmarek closed pull request #1512: Add missing consts

andrzej-kaczmarek closed pull request #1512: Add missing consts
URL: https://github.com/apache/mynewt-core/pull/1512
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/sensor/include/sensor/sensor.h b/hw/sensor/include/sensor/sensor.h
index 688434993e..bedf034446 100644
--- a/hw/sensor/include/sensor/sensor.h
+++ b/hw/sensor/include/sensor/sensor.h
@@ -942,7 +942,8 @@ struct sensor *sensor_mgr_find_next_bytype(sensor_type_t type, struct sensor *se
  *
  * @return 0 on success, non-zero error code on failure
  */
-struct sensor *sensor_mgr_find_next_bydevname(char *devname, struct sensor *prev_cursor);
+struct sensor *sensor_mgr_find_next_bydevname(const char *devname,
+                                              struct sensor *prev_cursor);
 
 /**
  * Check if sensor type matches
@@ -961,7 +962,7 @@ int sensor_mgr_match_bytype(struct sensor *sensor, void *);
  * @param poll_rate The poll rate in milli seconds
  */
 int
-sensor_set_poll_rate_ms(char *devname, uint32_t poll_rate);
+sensor_set_poll_rate_ms(const char *devname, uint32_t poll_rate);
 
 /**
  * Set the sensor poll rate multiple based on the device name, sensor type
@@ -970,7 +971,7 @@ sensor_set_poll_rate_ms(char *devname, uint32_t poll_rate);
  * @param stt The sensor type trait
  */
 int
-sensor_set_n_poll_rate(char *devname, struct sensor_type_traits *stt);
+sensor_set_n_poll_rate(const char *devname, struct sensor_type_traits *stt);
 
 /**
  * Transmit OIC trigger
@@ -1017,7 +1018,7 @@ sensor_get_type_traits_bytype(sensor_type_t type, struct sensor *sensor);
  * @return NULL on failure, sensor struct on success
  */
 struct sensor *
-sensor_get_type_traits_byname(char *, struct sensor_type_traits **,
+sensor_get_type_traits_byname(const char *, struct sensor_type_traits **,
                               sensor_type_t);
 
 /**
@@ -1029,7 +1030,7 @@ sensor_get_type_traits_byname(char *, struct sensor_type_traits **,
  * @return 0 on success, non-zero on failure
  */
 int
-sensor_set_thresh(char *devname, struct sensor_type_traits *stt);
+sensor_set_thresh(const char *devname, struct sensor_type_traits *stt);
 
 /**
  * Clears the low threshold for a sensor
@@ -1040,7 +1041,7 @@ sensor_set_thresh(char *devname, struct sensor_type_traits *stt);
  * @return 0 on success, non-zero on failure
  */
 int
-sensor_clear_low_thresh(char *devname, sensor_type_t type);
+sensor_clear_low_thresh(const char *devname, sensor_type_t type);
 
 /**
  * Clears the high threshold for a sensor
@@ -1051,7 +1052,7 @@ sensor_clear_low_thresh(char *devname, sensor_type_t type);
  * @return 0 on success, non-zero on failure
  */
 int
-sensor_clear_high_thresh(char *devname, sensor_type_t type);
+sensor_clear_high_thresh(const char *devname, sensor_type_t type);
 
 /**
  * Puts a notification event on the sensor manager evq
diff --git a/hw/sensor/src/sensor.c b/hw/sensor/src/sensor.c
index 7d84627c7d..634fccab00 100644
--- a/hw/sensor/src/sensor.c
+++ b/hw/sensor/src/sensor.c
@@ -240,7 +240,7 @@ sensor_insert_type_trait(struct sensor *sensor, struct sensor_type_traits *stt)
  * @param The sensor type trait
  */
 int
-sensor_set_n_poll_rate(char *devname, struct sensor_type_traits *stt)
+sensor_set_n_poll_rate(const char *devname, struct sensor_type_traits *stt)
 {
     struct sensor *sensor;
     struct sensor_type_traits *stt_tmp;
@@ -377,7 +377,7 @@ sensor_update_nextrun(struct sensor *sensor, os_time_t now)
  * @param The poll rate in milli seconds
  */
 int
-sensor_set_poll_rate_ms(char *devname, uint32_t poll_rate)
+sensor_set_poll_rate_ms(const char *devname, uint32_t poll_rate)
 {
     struct sensor *sensor;
     os_time_t next_wakeup;
@@ -837,9 +837,9 @@ sensor_get_type_traits_bytype(sensor_type_t type, struct sensor *sensor)
  * @return 0 on success, non-zero error code on failure
  */
 struct sensor *
-sensor_mgr_find_next_bydevname(char *devname, struct sensor *prev_cursor)
+sensor_mgr_find_next_bydevname(const char *devname, struct sensor *prev_cursor)
 {
-    return (sensor_mgr_find_next(sensor_mgr_match_bydevname, devname,
+    return (sensor_mgr_find_next(sensor_mgr_match_bydevname, (char *)devname,
             prev_cursor));
 }
 
@@ -1320,7 +1320,8 @@ sensor_up_timestamp(struct sensor *sensor)
  * @return NULL on failure, sensor struct on success
  */
 struct sensor *
-sensor_get_type_traits_byname(char *devname, struct sensor_type_traits **stt,
+sensor_get_type_traits_byname(const char *devname,
+                              struct sensor_type_traits **stt,
                               sensor_type_t type)
 {
     struct sensor *sensor;
@@ -1957,7 +1958,7 @@ sensor_set_trigger_cmp_algo(struct sensor *sensor, struct sensor_type_traits *st
  * @return 0 on success, non-zero on failure
  */
 int
-sensor_set_thresh(char *devname, struct sensor_type_traits *stt)
+sensor_set_thresh(const char *devname, struct sensor_type_traits *stt)
 {
     struct sensor_type_traits *stt_tmp;
     struct sensor *sensor;
@@ -2021,7 +2022,7 @@ sensor_set_thresh(char *devname, struct sensor_type_traits *stt)
  * @return 0 on success, non-zero on failure
  */
 int
-sensor_clear_low_thresh(char *devname, sensor_type_t type)
+sensor_clear_low_thresh(const char *devname, sensor_type_t type)
 {
     struct sensor *sensor;
     struct sensor_type_traits *stt_tmp;
@@ -2062,7 +2063,7 @@ sensor_clear_low_thresh(char *devname, sensor_type_t type)
  * @return 0 on success, non-zero on failure
  */
 int
-sensor_clear_high_thresh(char *devname, sensor_type_t type)
+sensor_clear_high_thresh(const char *devname, sensor_type_t type)
 {
     struct sensor *sensor;
     struct sensor_type_traits *stt_tmp;
diff --git a/sys/stats/full/include/stats/stats.h b/sys/stats/full/include/stats/stats.h
index 1763b6ab8e..f5fa41a802 100644
--- a/sys/stats/full/include/stats/stats.h
+++ b/sys/stats/full/include/stats/stats.h
@@ -33,7 +33,7 @@ struct stats_name_map {
 } __attribute__((packed));
 
 struct stats_hdr {
-    char *s_name;
+    const char *s_name;
     uint8_t s_size;
     uint8_t s_cnt;
     uint16_t s_pad1;
@@ -115,10 +115,10 @@ const struct stats_name_map STATS_NAME_MAP_NAME(__sectname)[] = {
 
 int stats_init(struct stats_hdr *shdr, uint8_t size, uint8_t cnt,
     const struct stats_name_map *map, uint8_t map_cnt);
-int stats_register(char *name, struct stats_hdr *shdr);
+int stats_register(const char *name, struct stats_hdr *shdr);
 int stats_init_and_reg(struct stats_hdr *shdr, uint8_t size, uint8_t cnt,
                        const struct stats_name_map *map, uint8_t map_cnt,
-                       char *name);
+                       const char *name);
 void stats_reset(struct stats_hdr *shdr);
 
 typedef int (*stats_walk_func_t)(struct stats_hdr *, void *, char *,
@@ -128,7 +128,7 @@ int stats_walk(struct stats_hdr *, stats_walk_func_t, void *);
 typedef int (*stats_group_walk_func_t)(struct stats_hdr *, void *);
 int stats_group_walk(stats_group_walk_func_t, void *);
 
-struct stats_hdr *stats_group_find(char *name);
+struct stats_hdr *stats_group_find(const char *name);
 
 /* Private */
 #if MYNEWT_VAL(STATS_NEWTMGR)
diff --git a/sys/stats/full/src/stats.c b/sys/stats/full/src/stats.c
index efff11e362..2d601a93d1 100644
--- a/sys/stats/full/src/stats.c
+++ b/sys/stats/full/src/stats.c
@@ -263,7 +263,7 @@ stats_group_walk(stats_group_walk_func_t walk_func, void *arg)
  * @return statistic structure if found, NULL if not found.
  */
 struct stats_hdr *
-stats_group_find(char *name)
+stats_group_find(const char *name)
 {
     struct stats_hdr *cur;
 
@@ -289,7 +289,7 @@ stats_group_find(char *name)
  * @return 0 on success, non-zero error code on failure.
  */
 int
-stats_register(char *name, struct stats_hdr *shdr)
+stats_register(const char *name, struct stats_hdr *shdr)
 {
     struct stats_hdr *cur;
     int rc;
@@ -332,7 +332,7 @@ stats_register(char *name, struct stats_hdr *shdr)
 int
 stats_init_and_reg(struct stats_hdr *shdr, uint8_t size, uint8_t cnt,
                    const struct stats_name_map *map, uint8_t map_cnt,
-                   char *name)
+                   const char *name)
 {
     int rc;
 
diff --git a/sys/stats/stub/include/stats/stats.h b/sys/stats/stub/include/stats/stats.h
index f91a63e294..dc469a387d 100644
--- a/sys/stats/stub/include/stats/stats.h
+++ b/sys/stats/stub/include/stats/stats.h
@@ -32,7 +32,7 @@ struct stats_name_map {
 } __attribute__((packed));
 
 struct stats_hdr {
-    char *s_name;
+    const char *s_name;
     uint8_t s_size;
     uint8_t s_cnt;
     uint16_t s_pad1;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services