From 7a260f01ce6841658810dc9f0ff0706558a10d7f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 19 Jun 2006 03:20:03 +0000 Subject: [PATCH] Make some 64 bit warnings go away on x86-64. --- coreutils/who.c | 17 ++++++++--------- e2fsprogs/e2fsck.c | 41 ++++++++--------------------------------- networking/ping6.c | 4 ++-- shell/lash.c | 12 +++++------- util-linux/nfsmount.c | 12 ++---------- util-linux/nfsmount.h | 2 +- 6 files changed, 26 insertions(+), 62 deletions(-) diff --git a/coreutils/who.c b/coreutils/who.c index 0cb74313e..5cff65157 100644 --- a/coreutils/who.c +++ b/coreutils/who.c @@ -14,12 +14,9 @@ *---------------------------------------------------------------------- */ -#include -#include -#include -#include -#include #include "busybox.h" +#include +#include static const char * idle_string (time_t t) { @@ -33,7 +30,7 @@ static const char * idle_string (time_t t) sprintf (str, "%02d:%02d", (int) (s / (60 * 60)), (int) ((s % (60 * 60)) / 60)); - return (const char *) str; + return str; } return "old"; } @@ -52,14 +49,16 @@ int who_main(int argc, char **argv) printf("USER TTY IDLE TIME HOST\n"); while ((ut = getutent()) != NULL) { if (ut->ut_user[0] && ut->ut_type == USER_PROCESS) { + time_t thyme = ut->ut_tv.tv_sec; + /* ut->ut_line is device name of tty - "/dev/" */ name = concat_path_file("/dev", ut->ut_line); printf("%-10s %-8s %-8s %-12.12s %s\n", ut->ut_user, ut->ut_line, (stat(name, &st)) ? "?" : idle_string(st.st_atime), - ctime((time_t*)&(ut->ut_tv.tv_sec)) + 4, ut->ut_host); - free(name); + ctime(&thyme) + 4, ut->ut_host); + if (ENABLE_FEATURE_CLEAN_UP) free(name); } } - endutent(); + if (ENABLE_FEATURE_CLEAN_UP) endutent(); return 0; } diff --git a/e2fsprogs/e2fsck.c b/e2fsprogs/e2fsck.c index ceafaea4b..0d151ef80 100644 --- a/e2fsprogs/e2fsck.c +++ b/e2fsprogs/e2fsck.c @@ -3,9 +3,6 @@ * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * Copyright (C) 2006 Garrett Kajmowicz - * This file may be - * redistributed under the terms of the GNU Public License. - * * * Dictionary Abstract Data Type * Copyright (C) 1997 Kaz Kylheku @@ -25,12 +22,10 @@ * * Copyright 1999-2000 Red Hat Software --- All Rights Reserved * - * This file is part of the Linux kernel and is made available under - * the terms of the GNU General Public License, version 2, or at your - * option, any later version, incorporated herein by reference. - * * Journal recovery routines for the generic filesystem journaling code; * part of the ext2fs journaling system. + * + * Licensed under GPLv2 or later, see file License in this tarball for details. */ #ifndef _GNU_SOURCE @@ -2532,16 +2527,8 @@ static void expand_inode_expression(char ch, if (LINUX_S_ISDIR(inode->i_mode)) printf("%u", inode->i_size); else { -#ifdef EXT2_NO_64_TYPE - if (inode->i_size_high) - printf("0x%x%08x", inode->i_size_high, - inode->i_size); - else - printf("%u", inode->i_size); -#else - printf("%llu", (inode->i_size | - ((__u64) inode->i_size_high << 32))); -#endif + printf("%"PRIu64, (inode->i_size | + ((uint64_t) inode->i_size_high << 32))); } break; case 'S': @@ -2649,11 +2636,7 @@ static void expand_percent_expression(ext2_filsys fs, char ch, printf("%u", ctx->blk); break; case 'B': -#ifdef EXT2_NO_64_TYPE - printf("%d", ctx->blkcount); -#else - printf("%lld", ctx->blkcount); -#endif + printf("%"PRIi64, ctx->blkcount); break; case 'c': printf("%u", ctx->blk2); @@ -2674,11 +2657,7 @@ static void expand_percent_expression(ext2_filsys fs, char ch, printf("%s", error_message(ctx->errcode)); break; case 'N': -#ifdef EXT2_NO_64_TYPE - printf("%u", ctx->num); -#else - printf("%llu", ctx->num); -#endif + printf("%"PRIi64, ctx->num); break; case 'p': print_pathname(fs, ctx->ino, 0); @@ -2700,11 +2679,7 @@ static void expand_percent_expression(ext2_filsys fs, char ch, printf("%s", ctx->str ? ctx->str : "NULL"); break; case 'X': -#ifdef EXT2_NO_64_TYPE - printf("0x%x", ctx->num); -#else - printf("0x%llx", ctx->num); -#endif + printf("0x%"PRIi64, ctx->num); break; default: no_context: @@ -4436,7 +4411,7 @@ static int process_bad_block(ext2_filsys fs FSCK_ATTR((unused)), * inode, which is never compressed. So we don't use HOLE_BLKADDR(). */ - printf("Unrecoverable Error: Found %lli bad blocks starting at block number: %u\n", blockcnt, *block_nr); + printf("Unrecoverable Error: Found %"PRIi64" bad blocks starting at block number: %u\n", blockcnt, *block_nr); return BLOCK_ERROR; } diff --git a/networking/ping6.c b/networking/ping6.c index 1cff59d4b..c15ea5c4a 100644 --- a/networking/ping6.c +++ b/networking/ping6.c @@ -311,7 +311,7 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit return; printf("%d bytes from %s: icmp6_seq=%u", sz, - inet_ntop(AF_INET6, (struct in_addr6 *) &pingaddr.sin6_addr, + inet_ntop(AF_INET6, &pingaddr.sin6_addr, buf, sizeof(buf)), icmppkt->icmp6_seq); printf(" ttl=%d time=%lu.%lu ms", hoplimit, @@ -392,7 +392,7 @@ static void ping(const char *host) printf("PING %s (%s): %d data bytes\n", hostent->h_name, - inet_ntop(AF_INET6, (struct in_addr6 *) &pingaddr.sin6_addr, + inet_ntop(AF_INET6, &pingaddr.sin6_addr, buf, sizeof(buf)), datalen); diff --git a/shell/lash.c b/shell/lash.c index eebb2f8a2..27eb8ec29 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -243,7 +243,7 @@ static int builtin_exec(struct child_prog *child) if (child->argv[1] == NULL) return EXIT_SUCCESS; /* Really? */ child->argv++; - while(close_me_list) close((int)llist_pop(&close_me_list)); + while(close_me_list) close((long)llist_pop(&close_me_list)); pseudo_exec(child); /* never returns */ } @@ -433,7 +433,6 @@ static int builtin_source(struct child_prog *child) { FILE *input; int status; - int fd; if (child->argv[1] == NULL) return EXIT_FAILURE; @@ -444,8 +443,7 @@ static int builtin_source(struct child_prog *child) return EXIT_FAILURE; } - fd=fileno(input); - llist_add_to(&close_me_list, (void *)fd); + llist_add_to(&close_me_list, (void *)(long)fileno(input)); /* Now run the file */ status = busy_loop(input); fclose(input); @@ -1339,7 +1337,7 @@ static int run_command(struct job *newjob, int inbg, int outpipe[2]) signal(SIGCHLD, SIG_DFL); // Close all open filehandles. - while(close_me_list) close((int)llist_pop(&close_me_list)); + while(close_me_list) close((long)llist_pop(&close_me_list)); if (outpipe[1]!=-1) { close(outpipe[0]); @@ -1570,7 +1568,7 @@ int lash_main(int argc_l, char **argv_l) FILE *prof_input; prof_input = fopen("/etc/profile", "r"); if (prof_input) { - llist_add_to(&close_me_list, (void *)fileno(prof_input)); + llist_add_to(&close_me_list, (void *)(long)fileno(prof_input)); /* Now run the file */ busy_loop(prof_input); fclose(prof_input); @@ -1618,7 +1616,7 @@ int lash_main(int argc_l, char **argv_l) //printf( "optind=%d argv[optind]='%s'\n", optind, argv[optind]); input = bb_xfopen(argv[optind], "r"); /* be lazy, never mark this closed */ - llist_add_to(&close_me_list, (void *)fileno(input)); + llist_add_to(&close_me_list, (void *)(long)fileno(input)); } /* initialize the cwd -- this is never freed...*/ diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c index d46cf698a..705975d29 100644 --- a/util-linux/nfsmount.c +++ b/util-linux/nfsmount.c @@ -3,15 +3,7 @@ * nfsmount.c -- Linux NFS mount * Copyright (C) 1993 Rick Sladkey * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. * * Wed Feb 8 12:51:48 1995, biro@yggdrasil.com (Ross Biro): allow all port * numbers to be specified on the command line. @@ -965,7 +957,7 @@ xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp) { if (!xdr_fhandle3 (xdrs, &objp->fhandle)) return FALSE; - if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (unsigned int *) &objp->auth_flavours.auth_flavours_len, ~0, + if (!xdr_array (xdrs, &(objp->auth_flavours.auth_flavours_val), &(objp->auth_flavours.auth_flavours_len), ~0, sizeof (int), (xdrproc_t) xdr_int)) return FALSE; return TRUE; diff --git a/util-linux/nfsmount.h b/util-linux/nfsmount.h index 78a1bdfc5..60e2019b4 100644 --- a/util-linux/nfsmount.h +++ b/util-linux/nfsmount.h @@ -91,7 +91,7 @@ struct mountres3_ok { fhandle3 fhandle; struct { unsigned int auth_flavours_len; - int *auth_flavours_val; + char *auth_flavours_val; } auth_flavours; }; typedef struct mountres3_ok mountres3_ok;