Commit d3a7576f authored by Urvang Joshi's avatar Urvang Joshi Committed by Yaowu Xu
Browse files

Add compiler flag -Wsign-compare

Also, fix the warnings generated by this flag.

Conflicts:
	examples/aom_cx_set_ref.c

Change-Id: I0451e119c52000aa7c1c55027d53f1da5a02a11f
parent 97aa09f6
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent. * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/ */
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
...@@ -119,13 +120,13 @@ void arg_show_usage(FILE *fp, const struct arg_def *const *defs) { ...@@ -119,13 +120,13 @@ void arg_show_usage(FILE *fp, const struct arg_def *const *defs) {
} }
unsigned int arg_parse_uint(const struct arg *arg) { unsigned int arg_parse_uint(const struct arg *arg) {
long int rawval; uint32_t rawval;
char *endptr; char *endptr;
rawval = strtol(arg->val, &endptr, 10); rawval = strtoul(arg->val, &endptr, 10);
if (arg->val[0] != '\0' && endptr[0] == '\0') { if (arg->val[0] != '\0' && endptr[0] == '\0') {
if (rawval >= 0 && rawval <= UINT_MAX) return rawval; if (rawval <= UINT_MAX) return rawval;
die("Option %s: Value %ld out of range for unsigned int\n", arg->name, die("Option %s: Value %ld out of range for unsigned int\n", arg->name,
rawval); rawval);
...@@ -136,7 +137,7 @@ unsigned int arg_parse_uint(const struct arg *arg) { ...@@ -136,7 +137,7 @@ unsigned int arg_parse_uint(const struct arg *arg) {
} }
int arg_parse_int(const struct arg *arg) { int arg_parse_int(const struct arg *arg) {
long int rawval; int32_t rawval;
char *endptr; char *endptr;
rawval = strtol(arg->val, &endptr, 10); rawval = strtol(arg->val, &endptr, 10);
......
...@@ -605,6 +605,7 @@ process_toolchain() { ...@@ -605,6 +605,7 @@ process_toolchain() {
check_add_cflags -Wimplicit-function-declaration check_add_cflags -Wimplicit-function-declaration
check_add_cflags -Wuninitialized check_add_cflags -Wuninitialized
check_add_cflags -Wunused-variable check_add_cflags -Wunused-variable
check_add_cflags -Wsign-compare
case ${CC} in case ${CC} in
*clang*) ;; *clang*) ;;
*) check_add_cflags -Wunused-but-set-variable ;; *) check_add_cflags -Wunused-but-set-variable ;;
......
...@@ -307,6 +307,7 @@ int main(int argc, char **argv) { ...@@ -307,6 +307,7 @@ int main(int argc, char **argv) {
const char *height_arg = NULL; const char *height_arg = NULL;
const char *infile_arg = NULL; const char *infile_arg = NULL;
const char *outfile_arg = NULL; const char *outfile_arg = NULL;
const char *update_frame_num_arg = NULL;
unsigned int limit = 0; unsigned int limit = 0;
exec_name = argv[0]; exec_name = argv[0];
...@@ -317,18 +318,21 @@ int main(int argc, char **argv) { ...@@ -317,18 +318,21 @@ int main(int argc, char **argv) {
height_arg = argv[3]; height_arg = argv[3];
infile_arg = argv[4]; infile_arg = argv[4];
outfile_arg = argv[5]; outfile_arg = argv[5];
update_frame_num_arg = argv[6];
encoder = get_aom_encoder_by_name(codec_arg); encoder = get_aom_encoder_by_name(codec_arg);
if (!encoder) die("Unsupported codec."); if (!encoder) die("Unsupported codec.");
update_frame_num = atoi(argv[6]); update_frame_num = (unsigned int)strtoul(update_frame_num_arg, NULL, 0);
// In AV1, the reference buffers (cm->buffer_pool->frame_bufs[i].buf) are // In AV1, the reference buffers (cm->buffer_pool->frame_bufs[i].buf) are
// allocated while calling aom_codec_encode(), thus, setting reference for // allocated while calling aom_codec_encode(), thus, setting reference for
// 1st frame isn't supported. // 1st frame isn't supported.
if (update_frame_num <= 1) die("Couldn't parse frame number '%s'\n", argv[6]); if (update_frame_num <= 1) {
die("Couldn't parse frame number '%s'\n", update_frame_num_arg);
}
if (argc > 7) { if (argc > 7) {
limit = atoi(argv[7]); limit = (unsigned int)strtoul(argv[7], NULL, 0);
if (update_frame_num > limit) if (update_frame_num > limit)
die("Update frame number couldn't larger than limit\n"); die("Update frame number couldn't larger than limit\n");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment