From 3684de257a7e8932936a27d0fdb3ecb39653e624 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 23 Nov 2011 12:16:25 -0700 Subject: [PATCH] LU-871 build: change %L printk format to %ll The clang-analyzer static code analysis flagged %L format specifiers for printf/printk as deprecated, so change all of their uses to %ll. In a couple of files (checkstat.c and truncate.c) there are existing code style issues that need to be fixed before landing, in order to get a clean bill of health from checkpatch.pl. Signed-off-by: Andreas Dilger Change-Id: I1bc75a0f43b25de112f5ae8f2273b3dc46081d09 Reviewed-on: http://review.whamcloud.com/1734 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/linux/kp30.h | 10 ++++----- libcfs/include/libcfs/posix/posix-wordsize.h | 22 ++++++++++---------- lnet/utils/routerstat.c | 29 +++++++++++++------------- lustre/fid/lproc_fid.c | 3 ++- lustre/include/lustre_debug.h | 4 ++-- lustre/liblustre/super.c | 4 ++-- lustre/llite/file.c | 4 ++-- lustre/llite/rw.c | 2 +- lustre/tests/checkstat.c | 31 +++++++++++++++------------- lustre/tests/truncate.c | 24 ++++++++++----------- lustre/utils/gss/lgss_keyring.c | 4 ++-- lustre/utils/gss/lgss_utils.c | 2 +- 12 files changed, 72 insertions(+), 67 deletions(-) diff --git a/libcfs/include/libcfs/linux/kp30.h b/libcfs/include/libcfs/linux/kp30.h index ff19b55..52acaa4 100644 --- a/libcfs/include/libcfs/linux/kp30.h +++ b/libcfs/include/libcfs/linux/kp30.h @@ -301,11 +301,11 @@ extern int lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size, #if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \ (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG)) -# define LPU64 "%Lu" -# define LPD64 "%Ld" -# define LPX64 "%#Lx" -# define LPX64i "%Lx" -# define LPO64 "%#Lo" +# define LPU64 "%llu" +# define LPD64 "%lld" +# define LPX64 "%#llx" +# define LPX64i "%llx" +# define LPO64 "%#llo" # define LPF64 "L" #else # define LPU64 "%lu" diff --git a/libcfs/include/libcfs/posix/posix-wordsize.h b/libcfs/include/libcfs/posix/posix-wordsize.h index e6730cd..4c80923 100644 --- a/libcfs/include/libcfs/posix/posix-wordsize.h +++ b/libcfs/include/libcfs/posix/posix-wordsize.h @@ -115,18 +115,18 @@ typedef struct { #if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \ (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG)) /* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */ -# define LPU64 "%Lu" -# define LPD64 "%Ld" -# define LPX64 "%#Lx" -# define LPX64i "%Lx" -# define LPO64 "%#Lo" -# define LPF64 "L" +# define LPU64 "%llu" +# define LPD64 "%lld" +# define LPX64 "%#llx" +# define LPX64i "%llx" +# define LPO64 "%#llo" +# define LPF64 "ll" #elif (BITS_PER_LONG == 32) -# define LPU64 "%Lu" -# define LPD64 "%Ld" -# define LPX64 "%#Lx" -# define LPX64i "%Lx" -# define LPO64 "%#Lo" +# define LPU64 "%llu" +# define LPD64 "%lld" +# define LPX64 "%#llx" +# define LPX64i "%llx" +# define LPO64 "%#llo" # define LPF64 "L" #elif (BITS_PER_LONG == 64) # define LPU64 "%lu" diff --git a/lnet/utils/routerstat.c b/lnet/utils/routerstat.c index 2f3474b..61d152c 100644 --- a/lnet/utils/routerstat.c +++ b/lnet/utils/routerstat.c @@ -47,7 +47,7 @@ double timenow () { struct timeval tv; - + gettimeofday (&tv, NULL); return (tv.tv_sec + tv.tv_usec / 1000000.0); } @@ -70,7 +70,7 @@ unsigned long long subull(unsigned long long a, unsigned long long b) { if (a < b) return -1ULL - b + a + 1; - + return a - b; } @@ -78,7 +78,7 @@ unsigned long long subul(unsigned long a, unsigned long b) { if (a < b) return -1UL - b + a + 1; - + return a - b; } @@ -103,7 +103,7 @@ do_stat (int fd) counters_t new_counter; counters_t counter; int n; - + lseek (fd, 0, SEEK_SET); now = timenow(); n = read (fd, buffer, sizeof (buffer)); @@ -111,10 +111,10 @@ do_stat (int fd) { fprintf (stderr, "Can't read statfile\n"); exit (1); - } + } buffer[n] = 0; - - n = sscanf (buffer, "%lu %lu %lu %lu %lu %lu %lu %Lu %Lu %Lu %Lu", + + n = sscanf(buffer, "%lu %lu %lu %lu %lu %lu %lu %llu %llu %llu %llu", &new_counter.msgs_alloc, &new_counter.msgs_max, &new_counter.errors, &new_counter.send_count, &new_counter.recv_count, @@ -126,9 +126,10 @@ do_stat (int fd) fprintf (stderr, "Can't parse statfile\n"); exit (1); } - + if (last == 0.0) { - printf ("M %lu(%lu) E %lu S %llu/%lu R %llu/%lu F %llu/%lu D %llu/%lu\n", + printf("M %lu(%lu) E %lu S %llu/%lu R %llu/%lu F %llu/%lu " + "D %llu/%lu\n", new_counter.msgs_alloc, new_counter.msgs_max, new_counter.errors, new_counter.send_length, new_counter.send_count, @@ -140,7 +141,7 @@ do_stat (int fd) counter.msgs_alloc = new_counter.msgs_alloc; counter.msgs_max = new_counter.msgs_max; - + counter.errors = subul(new_counter.errors, old_counter.errors); counter.send_count = subul(new_counter.send_count, old_counter.send_count); counter.recv_count = subul(new_counter.recv_count, old_counter.recv_count); @@ -162,7 +163,7 @@ do_stat (int fd) old_counter = new_counter; fflush (stdout); - + lseek (fd, 0, SEEK_SET); last = timenow(); } @@ -171,7 +172,7 @@ int main (int argc, char **argv) { int interval = 0; int fd; - + if (argc > 1) interval = atoi (argv[1]); @@ -181,11 +182,11 @@ int main (int argc, char **argv) fprintf (stderr, "Can't open stat: %s\n", strerror (errno)); return (1); } - + do_stat (fd); if (interval == 0) return (0); - + for (;;) { sleep (interval); diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c index 633607d..cf70a68 100644 --- a/lustre/fid/lproc_fid.c +++ b/lustre/fid/lproc_fid.c @@ -77,7 +77,8 @@ seq_proc_write_common(struct file *file, const char *buffer, LASSERT(range != NULL); - rc = sscanf(buffer, "[%Lx - %Lx]\n",(long long unsigned *)&tmp.lsr_start, + rc = sscanf(buffer, "[%llx - %llx]\n", + (long long unsigned *)&tmp.lsr_start, (long long unsigned *)&tmp.lsr_end); if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp)) RETURN(-EINVAL); diff --git a/lustre/include/lustre_debug.h b/lustre/include/lustre_debug.h index 6662f48..ea988c0 100644 --- a/lustre/include/lustre_debug.h +++ b/lustre/include/lustre_debug.h @@ -58,7 +58,7 @@ #define ASSERT_MAX_SIZE_MB 60000ULL #define ASSERT_PAGE_INDEX(index, OP) \ do { if (index > ASSERT_MAX_SIZE_MB << (20 - CFS_PAGE_SHIFT)) { \ - CERROR("bad page index %lu > %Lu\n", index, \ + CERROR("bad page index %lu > %llu\n", index, \ ASSERT_MAX_SIZE_MB << (20 - CFS_PAGE_SHIFT)); \ libcfs_debug = ~0UL; \ OP; \ @@ -66,7 +66,7 @@ do { if (index > ASSERT_MAX_SIZE_MB << (20 - CFS_PAGE_SHIFT)) { \ #define ASSERT_FILE_OFFSET(offset, OP) \ do { if (offset > ASSERT_MAX_SIZE_MB << 20) { \ - CERROR("bad file offset %Lu > %Lu\n", offset, \ + CERROR("bad file offset %llu > %llu\n", offset, \ ASSERT_MAX_SIZE_MB << 20); \ libcfs_debug = ~0UL; \ OP; \ diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 447481e..5bf3558 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -314,8 +314,8 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo, OBD_MD_FLSIZE; obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid); - CDEBUG(D_INODE, "objid "LPX64" size %Lu, blocks %Lu, " - "blksize %Lu\n", lli->lli_smd->lsm_object_id, + CDEBUG(D_INODE, "objid "LPX64" size %llu, blocks %llu, " + "blksize %llu\n", lli->lli_smd->lsm_object_id, (long long unsigned)llu_i2stat(inode)->st_size, (long long unsigned)llu_i2stat(inode)->st_blocks, (long long unsigned)llu_i2stat(inode)->st_blksize); diff --git a/lustre/llite/file.c b/lustre/llite/file.c index eefa640..bcff3e6 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -748,7 +748,7 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo, if (rc == 0) { obdo_refresh_inode(inode, obdo, obdo->o_valid); CDEBUG(D_INODE, - "objid "LPX64" size %Lu, blocks %llu, blksize %lu\n", + "objid "LPX64" size %llu, blocks %llu, blksize %lu\n", lli->lli_smd->lsm_object_id, i_size_read(inode), (unsigned long long)inode->i_blocks, (unsigned long)ll_inode_blksize(inode)); @@ -1867,7 +1867,7 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) ENTRY; retval = offset + ((origin == 2) ? i_size_read(inode) : (origin == 1) ? file->f_pos : 0); - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), to=%Lu=%#Lx(%s)\n", + CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), to=%llu=%#llx(%s)\n", inode->i_ino, inode->i_generation, inode, retval, retval, origin == 2 ? "SEEK_END": origin == 1 ? "SEEK_CUR" : "SEEK_SET"); ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LLSEEK, 1); diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 93fb344..065fbc7 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -76,7 +76,7 @@ void ll_truncate(struct inode *inode) struct ll_inode_info *lli = ll_i2info(inode); ENTRY; - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) to %Lu\n",inode->i_ino, + CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) to %llu\n", inode->i_ino, inode->i_generation, inode, i_size_read(inode)); ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_TRUNC, 1); diff --git a/lustre/tests/checkstat.c b/lustre/tests/checkstat.c index 4980b05..5975efa 100644 --- a/lustre/tests/checkstat.c +++ b/lustre/tests/checkstat.c @@ -30,6 +30,11 @@ * Use is subject to license terms. */ /* + * Test program to compare the attributes of a files to verify that it + * desired file attributes are present. This file predates availability + * of the stat(3) utility and is deprecated. Either test(3) ([ ]) or + * stat(3) should be used in all new tests. + * * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. */ @@ -276,20 +281,18 @@ main (int argc, char **argv) fname, perms); } - if (size != -1) - { - if (buf.st_size != size) - { - if (verbose) - printf ("%s has size %Ld, not %Ld\n", - fname, (long long)buf.st_size, - size); - return (1); - } - - if (verbose) - printf ("%s has size %Ld OK\n", fname, size); - } + if (size != -1) { + if (buf.st_size != size) { + if (verbose) + printf("%s has size %lld, not %lld\n", + fname, (long long)buf.st_size, + size); + return 1; + } + + if (verbose) + printf("%s has size %lld OK\n", fname, size); + } if (checklink != NULL) { diff --git a/lustre/tests/truncate.c b/lustre/tests/truncate.c index 910f870..1339686 100644 --- a/lustre/tests/truncate.c +++ b/lustre/tests/truncate.c @@ -42,19 +42,19 @@ int main(int argc, char **argv) { - unsigned long long off; - int err; + unsigned long long off; + int err; - if (argc != 3) { - printf("usage %s file bytes\n", argv[0]); - return 1; - } + if (argc != 3) { + printf("usage %s file bytes\n", argv[0]); + return 1; + } - off = strtoull(argv[2], NULL, 0); - err = truncate64(argv[1], off); - if ( err ) - printf("Error truncating %s to %Ld: %s\n", argv[1], off, - strerror(errno)); + off = strtoull(argv[2], NULL, 0); + err = truncate64(argv[1], off); + if (err) + printf("Error truncating %s to %lld: %s\n", argv[1], off, + strerror(errno)); - return err; + return err; } diff --git a/lustre/utils/gss/lgss_keyring.c b/lustre/utils/gss/lgss_keyring.c index 26777767..5414694 100644 --- a/lustre/utils/gss/lgss_keyring.c +++ b/lustre/utils/gss/lgss_keyring.c @@ -474,7 +474,7 @@ static int lgssc_kr_negotiate(key_serial_t keyid, struct lgss_cred *cred, int rc = -1; logmsg(LL_TRACE, "child start on behalf of key %08x: " - "cred %p, uid %u, svc %u, nid %Lx, uids: %u:%u/%u:%u\n", + "cred %p, uid %u, svc %u, nid %llx, uids: %u:%u/%u:%u\n", keyid, cred, cred->lc_uid, cred->lc_tgt_svc, cred->lc_tgt_nid, kup->kup_uid, kup->kup_gid, kup->kup_fsuid, kup->kup_fsgid); @@ -590,7 +590,7 @@ static int parse_callout_info(const char *coinfo, strncpy(uparam->kup_tgt, data[7], sizeof(uparam->kup_tgt)); logmsg(LL_DEBUG, "parse call out info: secid %d, mech %s, ugid %u:%u " - "is_root %d, is_mdt %d, is_ost %d, svc %d, nid 0x%Lx, tgt %s\n", + "is_root %d, is_mdt %d, is_ost %d, svc %d, nid 0x%llx, tgt %s\n", uparam->kup_secid, uparam->kup_mech, uparam->kup_uid, uparam->kup_gid, uparam->kup_is_root, uparam->kup_is_mdt, uparam->kup_is_ost, diff --git a/lustre/utils/gss/lgss_utils.c b/lustre/utils/gss/lgss_utils.c index c611218..ef9839d 100644 --- a/lustre/utils/gss/lgss_utils.c +++ b/lustre/utils/gss/lgss_utils.c @@ -430,7 +430,7 @@ int lgss_get_service_str(char **string, uint32_t lsvc, uint64_t tgt_nid) } if (lnet_nid2hostname(tgt_nid, namebuf, max_namelen)) { - logmsg(LL_ERR, "can't resolve hostname from nid %Lx\n",tgt_nid); + logmsg(LL_ERR,"can't resolve hostname from nid %llx\n",tgt_nid); return -1; } -- 1.8.3.1