vfs_full_audit: make do_log() printf-aware
authorUri Simchoni <uri@samba.org>
Sun, 19 Nov 2017 18:44:06 +0000 (18:44 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 24 Nov 2017 00:13:15 +0000 (01:13 +0100)
Add PRINTF_ATTRIBUTE() to do_log(). This removes
picky compiler warning about printf with variable
format string, and adds compiler checks for the format
strings supplied to do_log. This in turn spurred some
warnings which are fixed.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/modules/vfs_full_audit.c

index b8471593db7ec215d6092802ef0b490eb16540bb..fbe1715b90e0f9921eb0462b32480a2ebc00f5af 100644 (file)
@@ -520,6 +520,9 @@ static TALLOC_CTX *do_log_ctx(void)
         return tmp_do_log_ctx;
 }
 
+static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
+                  const char *format, ...) PRINTF_ATTRIBUTE(4, 5);
+
 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
                   const char *format, ...)
 {
@@ -1411,7 +1414,7 @@ static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
        result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
 
        do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result != (uint64_t)-1), handle,
-                       "%llu", result);
+                       "%llu", (unsigned long long)result);
 
        return result;
 }
@@ -1783,7 +1786,10 @@ static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle
        do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
            "%s:%llu-%llu. type=%d. blocking=%d",
               fsp_str_do_log(brl_fsp(br_lck)),
-           plock->start, plock->size, plock->lock_type, blocking_lock);
+              (unsigned long long)plock->start,
+              (unsigned long long)plock->size,
+              plock->lock_type,
+              blocking_lock);
 
        return result;
 }
@@ -1800,8 +1806,9 @@ static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
 
        do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
               "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck)),
-              plock->start,
-           plock->size, plock->lock_type);
+              (unsigned long long)plock->start,
+              (unsigned long long)plock->size,
+              plock->lock_type);
 
        return result;
 }
@@ -1816,8 +1823,9 @@ static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
 
        do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
               "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck)),
-              plock->start,
-           plock->size, plock->lock_type);
+              (unsigned long long)plock->start,
+              (unsigned long long)plock->size,
+              plock->lock_type);
 
        return result;
 }
@@ -1831,8 +1839,10 @@ static bool smb_full_audit_strict_lock_check(struct vfs_handle_struct *handle,
        result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
 
        do_log(SMB_VFS_OP_STRICT_LOCK_CHECK, result, handle,
-           "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
-           plock->size, plock->lock_type);
+              "%s:%llu-%llu:%d", fsp_str_do_log(fsp),
+              (unsigned long long)plock->start,
+              (unsigned long long)plock->size,
+              plock->lock_type);
 
        return result;
 }