summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUri Simchoni <uri@samba.org>2017-11-19 17:11:28 +0000
committerAndrew Bartlett <abartlet@samba.org>2017-11-24 01:13:15 +0100
commit559367ed60a316943d97a10a14ba11bcc01204c5 (patch)
treec036b864156a2193b5bcf54aa83f5ea5b7c0b9a7
parent899057012187954179297e1b3ae110e717702eba (diff)
downloadsamba-559367ed60a316943d97a10a14ba11bcc01204c5.tar.gz
s4-torture: fix truncation warnings
Fix various places where there is potential truncation while doing time / size calculations. Signed-off-by: Uri Simchoni <uri@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r--source4/torture/basic/base.c6
-rw-r--r--source4/torture/raw/open.c2
-rw-r--r--source4/torture/raw/qfileinfo.c2
-rw-r--r--source4/torture/raw/qfsinfo.c5
4 files changed, 8 insertions, 7 deletions
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 8e7ae498aef..314e8f2d131 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -190,7 +190,7 @@ static bool run_attrtest(struct torture_context *tctx,
torture_comment(tctx, "New file time is %s", ctime(&t));
- if (abs(t - time(NULL)) > 60*60*24*10) {
+ if (labs(t - time(NULL)) > 60*60*24*10) {
torture_result(tctx, TORTURE_FAIL, "ERROR: SMBgetatr bug. time is %s",
ctime(&t));
t = time(NULL);
@@ -289,13 +289,13 @@ static bool run_trans2test(struct torture_context *tctx,
torture_comment(tctx, "modify time=%s", ctime(&m_time));
torture_comment(tctx, "This system appears to have sticky create times\n");
}
- if ((abs(a_time - t) > 60) && (a_time % (60*60) == 0)) {
+ if ((labs(a_time - t) > 60) && (a_time % (60*60) == 0)) {
torture_comment(tctx, "access time=%s", ctime(&a_time));
torture_result(tctx, TORTURE_FAIL, "This system appears to set a midnight access time\n");
correct = false;
}
- if (abs(m_time - t) > 60*60*24*7) {
+ if (labs(m_time - t) > 60*60*24*7) {
torture_result(tctx, TORTURE_FAIL, "ERROR: totally incorrect times - maybe word reversed? mtime=%s", ctime(&m_time));
correct = false;
}
diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c
index 44b04acda9a..5e8c81c9d07 100644
--- a/source4/torture/raw/open.c
+++ b/source4/torture/raw/open.c
@@ -95,7 +95,7 @@ static const char *rdwr_string(enum rdwr_mode m)
CHECK_STATUS(status, NT_STATUS_OK); \
t1 = t & ~1; \
t2 = nt_time_to_unix(finfo.all_info.out.field) & ~1; \
- if (abs(t1-t2) > 2) { \
+ if (labs(t1-t2) > 2) { \
torture_result(tctx, TORTURE_FAIL, \
"(%s) wrong time for field %s %s - %s\n", \
__location__, #field, \
diff --git a/source4/torture/raw/qfileinfo.c b/source4/torture/raw/qfileinfo.c
index 3b89189aa5f..0c5daa3ccc3 100644
--- a/source4/torture/raw/qfileinfo.c
+++ b/source4/torture/raw/qfileinfo.c
@@ -140,7 +140,7 @@ static struct {
static int dos_nt_time_cmp(time_t t, NTTIME nt)
{
time_t t2 = nt_time_to_unix(nt);
- if (abs(t2 - t) <= 2) return 0;
+ if (labs(t2 - t) <= 2) return 0;
return t2 > t ? 1 : -1;
}
diff --git a/source4/torture/raw/qfsinfo.c b/source4/torture/raw/qfsinfo.c
index 259aee0e0ec..0f1717b9cb2 100644
--- a/source4/torture/raw/qfsinfo.c
+++ b/source4/torture/raw/qfsinfo.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include <math.h>
#include "libcli/libcli.h"
#include "torture/util.h"
#include "torture/basic/proto.h"
@@ -206,7 +207,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
s2->allocation.out.sectors_per_unit *
s2->allocation.out.total_alloc_units *
s2->allocation.out.bytes_per_sector / scale;
- if (abs(size1 - size2) > 1) {
+ if (fabs(size1 - size2) > 1) {
printf("Inconsistent total size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n",
size1, size2);
ret = false;
@@ -228,7 +229,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
s2->allocation.out.sectors_per_unit *
s2->allocation.out.avail_alloc_units *
s2->allocation.out.bytes_per_sector / scale;
- if (abs(size1 - size2) > 1) {
+ if (fabs(size1 - size2) > 1) {
printf("Inconsistent avail size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n",
size1, size2);
ret = false;