Skip to content

Commit 785a67f

Browse files
adriansmpalaych
authored andcommitted
power: Fix power hal compiler warnings
Bug: 30432975 Test: compile power hal for walleye without warnings Change-Id: I0d90c26462c662690f8a179250000b9a449a109f Signed-off-by: Arian <[email protected]>
1 parent 83ff274 commit 785a67f

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

Android.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ endif
130130
ifeq ($(call is-board-platform-in-list,trinket), true)
131131
LOCAL_MODULE := power.qcom
132132
LOCAL_MODULE_TAGS := optional
133-
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
134133
LOCAL_VENDOR_MODULE := true
135134
include $(BUILD_SHARED_LIBRARY)
136135
else

hint-data.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
*/
2929

30+
#include <utils/Log.h>
31+
3032
#include "hint-data.h"
3133

3234
int hint_compare(struct hint_data* first_hint, struct hint_data* other_hint) {
@@ -40,5 +42,5 @@ int hint_compare(struct hint_data* first_hint, struct hint_data* other_hint) {
4042
}
4143

4244
void hint_dump(struct hint_data* hint) {
43-
/*ALOGI("hint_id: %lu", hint->hint_id);*/
45+
ALOGV("hint_id: %lu", hint->hint_id);
4446
}

metadata-defs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ struct video_decode_metadata_t {
4646
int state;
4747
};
4848

49-
int parse_metadata(char* metadata, char** metadata_saveptr, char* attribute, int attribute_size,
50-
char* value, int value_size);
49+
int parse_metadata(char* metadata, char** metadata_saveptr, char* attribute,
50+
unsigned int attribute_size, char* value, unsigned int value_size);
5151
int parse_video_encode_metadata(char* metadata,
5252
struct video_encode_metadata_t* video_encode_metadata);
5353
int parse_video_decode_metadata(char* metadata,

metadata-parser.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
#include "metadata-defs.h"
3535

36-
int parse_metadata(char* metadata, char** metadata_saveptr, char* attribute, int attribute_size,
37-
char* value, int value_size) {
36+
int parse_metadata(char* metadata, char** metadata_saveptr, char* attribute,
37+
unsigned int attribute_size, char* value, unsigned int value_size) {
3838
char* attribute_string;
3939
char* attribute_value_delim;
4040
unsigned int bytes_to_copy;
@@ -46,15 +46,12 @@ int parse_metadata(char* metadata, char** metadata_saveptr, char* attribute, int
4646
attribute[0] = value[0] = '\0';
4747

4848
if ((attribute_value_delim = strchr(attribute_string, ATTRIBUTE_VALUE_DELIM)) != NULL) {
49-
bytes_to_copy = MIN((attribute_value_delim - attribute_string), attribute_size - 1);
50-
/* Replace strncpy with strlcpy
51-
* Add +1 to bytes_to_copy as strlcpy copies size-1 bytes */
52-
strlcpy(attribute, attribute_string, bytes_to_copy + 1);
53-
54-
bytes_to_copy = MIN(strlen(attribute_string) - strlen(attribute) - 1, value_size - 1);
55-
/* Replace strncpy with strlcpy
56-
* Add +1 to bytes_to_copy as strlcpy copies size-1 bytes */
57-
strlcpy(value, attribute_value_delim + 1, bytes_to_copy + 1);
49+
unsigned int attribute_len = (unsigned int)(attribute_value_delim - attribute_string);
50+
/* copy only attribute len + NUL character, or as much as can be fit */
51+
bytes_to_copy = MIN(attribute_len + 1, attribute_size);
52+
53+
strlcpy(attribute, attribute_string, bytes_to_copy);
54+
strlcpy(value, attribute_value_delim + 1, value_size);
5855
}
5956

6057
return METADATA_PARSING_CONTINUE;

0 commit comments

Comments
 (0)