mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
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>
This commit is contained in:
parent
8990570121
commit
559367ed60
@ -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;
|
||||
}
|
||||
|
@ -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, \
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user