diff options
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | hint-data.c | 4 | ||||
-rw-r--r-- | list.c | 2 | ||||
-rw-r--r-- | metadata-defs.h | 2 | ||||
-rw-r--r-- | metadata-parser.c | 21 | ||||
-rw-r--r-- | power-8996.c | 4 | ||||
-rw-r--r-- | power-8998.c | 4 | ||||
-rw-r--r-- | power-common.c | 6 | ||||
-rw-r--r-- | power-common.h | 2 |
9 files changed, 21 insertions, 25 deletions
@@ -80,7 +80,6 @@ endif LOCAL_MODULE := android.hardware.power@1.2-service LOCAL_INIT_RC := android.hardware.power@1.2-service.rc LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable LOCAL_VENDOR_MODULE := true include $(BUILD_EXECUTABLE) diff --git a/hint-data.c b/hint-data.c index 67da77a..f3403b7 100644 --- a/hint-data.c +++ b/hint-data.c @@ -27,6 +27,8 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <utils/Log.h> + #include "hint-data.h" int hint_compare(struct hint_data *first_hint, @@ -43,5 +45,5 @@ int hint_compare(struct hint_data *first_hint, void hint_dump(struct hint_data *hint) { - /*ALOGI("hint_id: %lu", hint->hint_id);*/ + ALOGV("hint_id: %lu", hint->hint_id); } @@ -114,7 +114,7 @@ void dump_list(struct list_node *head) if (head == NULL) return; - printf("List:\n"); + ALOGV("List:\n"); while ((current_node = current_node->next)) { if (current_node->dump) { diff --git a/metadata-defs.h b/metadata-defs.h index c464900..e3ce944 100644 --- a/metadata-defs.h +++ b/metadata-defs.h @@ -47,7 +47,7 @@ struct video_decode_metadata_t { }; int parse_metadata(char *metadata, char **metadata_saveptr, - char *attribute, int attribute_size, char *value, int value_size); + char *attribute, unsigned int attribute_size, char *value, unsigned int value_size); int parse_video_encode_metadata(char *metadata, struct video_encode_metadata_t *video_encode_metadata); int parse_video_decode_metadata(char *metadata, diff --git a/metadata-parser.c b/metadata-parser.c index c9122a4..ffe092b 100644 --- a/metadata-parser.c +++ b/metadata-parser.c @@ -34,7 +34,7 @@ #include "metadata-defs.h" int parse_metadata(char *metadata, char **metadata_saveptr, - char *attribute, int attribute_size, char *value, int value_size) + char *attribute, unsigned int attribute_size, char *value, unsigned int value_size) { char *attribute_string; char *attribute_value_delim; @@ -50,19 +50,12 @@ int parse_metadata(char *metadata, char **metadata_saveptr, if ((attribute_value_delim = strchr(attribute_string, ATTRIBUTE_VALUE_DELIM)) != NULL) { - bytes_to_copy = MIN((attribute_value_delim - attribute_string), - attribute_size - 1); - /* Replace strncpy with strlcpy - * Add +1 to bytes_to_copy as strlcpy copies size-1 bytes */ - strlcpy(attribute, attribute_string, - bytes_to_copy+1); - - bytes_to_copy = MIN(strlen(attribute_string) - strlen(attribute) - 1, - value_size - 1); - /* Replace strncpy with strlcpy - * Add +1 to bytes_to_copy as strlcpy copies size-1 bytes */ - strlcpy(value, attribute_value_delim + 1, - bytes_to_copy+1); + unsigned int attribute_len = (unsigned int) (attribute_value_delim - attribute_string); + /* copy only attribute len + NUL character, or as much as can be fit */ + bytes_to_copy = MIN(attribute_len + 1, attribute_size); + + strlcpy(attribute, attribute_string, bytes_to_copy); + strlcpy(value, attribute_value_delim + 1, value_size); } return METADATA_PARSING_CONTINUE; diff --git a/power-8996.c b/power-8996.c index 0b1c362..d796160 100644 --- a/power-8996.c +++ b/power-8996.c @@ -128,7 +128,7 @@ static int process_video_encode_hint(void *metadata) return HINT_NONE; } -int power_hint_override(struct power_module *module, power_hint_t hint, void *data) +int power_hint_override(struct power_module *UNUSED(module), power_hint_t hint, void *data) { int ret_val = HINT_NONE; switch(hint) { @@ -141,7 +141,7 @@ int power_hint_override(struct power_module *module, power_hint_t hint, void *da return ret_val; } -int set_interactive_override(struct power_module *module, int on) +int set_interactive_override(struct power_module *UNUSED(module), int on) { return HINT_HANDLED; /* Don't excecute this code path, not in use */ char governor[80]; diff --git a/power-8998.c b/power-8998.c index 651ddf5..f72b45a 100644 --- a/power-8998.c +++ b/power-8998.c @@ -193,7 +193,7 @@ static int process_video_encode_hint(void *metadata) return HINT_NONE; } -int power_hint_override(struct power_module *module, power_hint_t hint, void *data) +int power_hint_override(struct power_module *UNUSED(module), power_hint_t hint, void *data) { int ret_val = HINT_NONE; switch(hint) { @@ -219,7 +219,7 @@ int power_hint_override(struct power_module *module, power_hint_t hint, void *da return ret_val; } -int set_interactive_override(struct power_module *module, int on) +int set_interactive_override(struct power_module *UNUSED(module), int UNUSED(on)) { return HINT_HANDLED; /* Don't excecute this code path, not in use */ } diff --git a/power-common.c b/power-common.c index 0101bea..1dc9334 100644 --- a/power-common.c +++ b/power-common.c @@ -60,8 +60,8 @@ void power_init() } } -int __attribute__ ((weak)) power_hint_override(power_hint_t hint, - void *data) +int __attribute__ ((weak)) power_hint_override(power_hint_t UNUSED(hint), + void *UNUSED(data)) { return HINT_NONE; } @@ -112,7 +112,7 @@ void power_hint(power_hint_t hint, void *data) } } -int __attribute__ ((weak)) set_interactive_override(int on) +int __attribute__ ((weak)) set_interactive_override(int UNUSED(on)) { return HINT_NONE; } diff --git a/power-common.h b/power-common.h index 697302a..f586f09 100644 --- a/power-common.h +++ b/power-common.h @@ -62,6 +62,8 @@ void power_init(void); void power_hint(power_hint_t hint, void *data); void set_interactive(int on); +#define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) + #ifdef __cplusplus } #endif |