From: nicm Date: Mon, 5 Oct 2015 19:50:38 +0000 (+0000) Subject: Offset into the file can be size_t and add some casts to remove warnings. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=991466922fe2a2dfb2021ba8215b02b299731dc0;p=openbsd Offset into the file can be size_t and add some casts to remove warnings. --- diff --git a/usr.bin/file/magic-test.c b/usr.bin/file/magic-test.c index f2c72ea90a5..9f239c15ecf 100644 --- a/usr.bin/file/magic-test.c +++ b/usr.bin/file/magic-test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: magic-test.c,v 1.13 2015/08/12 09:39:43 nicm Exp $ */ +/* $OpenBSD: magic-test.c,v 1.14 2015/10/05 19:50:38 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -1135,7 +1135,7 @@ magic_test_line(struct magic_line *ml, struct magic_state *ms) else { wanted = ml->indirect_offset; if (ml->indirect_relative) { - if (wanted < 0 && -wanted > ms->offset) + if (wanted < 0 && (size_t)-wanted > ms->offset) return (0); if (wanted > 0 && ms->offset + wanted > ms->size) return (0); @@ -1186,14 +1186,14 @@ magic_test_line(struct magic_line *ml, struct magic_state *ms) } if (ml->offset_relative) { - if (wanted < 0 && -wanted > ms->offset) + if (wanted < 0 && (size_t)-wanted > ms->offset) return (0); if (wanted > 0 && ms->offset + wanted > ms->size) return (0); offset = ms->offset + wanted; } else offset = wanted; - if (offset < 0 || offset > ms->size) + if (offset < 0 || (size_t)offset > ms->size) return (0); ms->offset = offset; @@ -1213,7 +1213,7 @@ magic_test_line(struct magic_line *ml, struct magic_state *ms) if (ml->mimetype != NULL) ms->mimetype = ml->mimetype; - magic_warn(ml, "test %s/%c matched at offset %llu: '%s'", + magic_warn(ml, "test %s/%c matched at offset %zu: '%s'", ml->type_string, ml->test_operator, ms->offset, ml->result == NULL ? "" : ml->result); diff --git a/usr.bin/file/magic.h b/usr.bin/file/magic.h index 7fa2f3774db..106e90a5745 100644 --- a/usr.bin/file/magic.h +++ b/usr.bin/file/magic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: magic.h,v 1.9 2015/10/02 18:06:27 deraadt Exp $ */ +/* $OpenBSD: magic.h,v 1.10 2015/10/05 19:50:38 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -160,7 +160,7 @@ struct magic_state { const char *base; size_t size; - int64_t offset; + size_t offset; }; #define MAGIC_TEST_TEXT 0x1