*: suppress ~60% of "aliased warnings" on gcc-4.4.1
No binary (build failed)
—
(log yok)
| @@ -14,6 +14,10 @@ | |
| #include "libbb.h" | |
| #include "unarchive.h" | |
| + | typedef uint32_t aliased_uint32_t FIX_ALIASING; |
| + | typedef off_t aliased_off_t FIX_ALIASING; |
| + | |
| + | |
| /* | |
| * GNU tar uses "base-256 encoding" for very large numbers (>8 billion). | |
| * Encoding is binary, with highest bit always set as a marker | |
| @@ -68,10 +72,10 @@ static off_t getBase256_len12(const char *str) | |
| * and fetch it in one go: | |
| */ | |
| if (sizeof(off_t) == 8) { | |
| - | value = *(off_t*)str; |
| + | value = *(aliased_off_t*)str; |
| value = SWAP_BE64(value); | |
| } else if (sizeof(off_t) == 4) { | |
| - | value = *(off_t*)str; |
| + | value = *(aliased_off_t*)str; |
| value = SWAP_BE32(value); | |
| } else { | |
| value = 0; | |
| @@ -156,7 +160,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) | |
| #if ENABLE_DESKTOP || ENABLE_FEATURE_TAR_AUTODETECT | |
| /* to prevent misdetection of bz2 sig */ | |
| - | *(uint32_t*)(&tar) = 0; |
| + | *(aliased_uint32_t*)&tar = 0; |
| i = full_read(archive_handle->src_fd, &tar, 512); | |
| /* If GNU tar sees EOF in above read, it says: | |
| * "tar: A lone zero block at N", where N = kilobyte | |
| @@ -396,7 +396,7 @@ struct globals { | |
| const uint32_t *lzo_crc32_table; | |
| chksum_t chksum_in; | |
| chksum_t chksum_out; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { } while (0) | |
| //#define G (*ptr_to_globals) | |
| @@ -11,12 +11,12 @@ | |
| #define ESC "\033" | |
| - | #define old_termios (*(struct termios*)&bb_common_bufsiz1) |
| + | #define old_termios_p ((struct termios*)&bb_common_bufsiz1) |
| static void | |
| onintr(int sig UNUSED_PARAM) | |
| { | |
| - | tcsetattr(STDERR_FILENO, TCSANOW, &old_termios); |
| + | tcsetattr(STDERR_FILENO, TCSANOW, old_termios_p); |
| exit(EXIT_FAILURE); | |
| } | |
| @@ -33,8 +33,8 @@ int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |
| * and operate on it - should we do the same? | |
| */ | |
| - | tcgetattr(STDERR_FILENO, &old_termios); /* fiddle echo */ |
| - | new = old_termios; |
| + | tcgetattr(STDERR_FILENO, old_termios_p); /* fiddle echo */ |
| + | memcpy(&new, old_termios_p, sizeof(new)); |
| new.c_cflag |= (CLOCAL | CREAD); | |
| new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); | |
| bb_signals(0 | |
| @@ -61,7 +61,7 @@ int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |
| * (gotten via TIOCGWINSZ) and recomputing *pixel values */ | |
| ret = ioctl(STDERR_FILENO, TIOCSWINSZ, &w); | |
| - | tcsetattr(STDERR_FILENO, TCSANOW, &old_termios); |
| + | tcsetattr(STDERR_FILENO, TCSANOW, old_termios_p); |
| if (ENABLE_FEATURE_RESIZE_PRINT) | |
| printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n", | |
| @@ -38,7 +38,7 @@ struct globals { | |
| unsigned long long total_bytes; | |
| unsigned long long begin_time_us; | |
| #endif | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { \ | |
| /* we have to zero it out because of NOEXEC */ \ | |
| @@ -50,7 +50,7 @@ struct globals { | |
| int slink_depth; | |
| int du_depth; | |
| dev_t dir_dev; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| @@ -63,7 +63,7 @@ typedef struct valinfo VALUE; | |
| /* The arguments given to the program, minus the program name. */ | |
| struct globals { | |
| char **args; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| /* forward declarations */ | |
| @@ -255,7 +255,7 @@ struct globals { | |
| /* Do time() just once. Saves one syscall per file for "ls -l" */ | |
| time_t current_time_t; | |
| #endif | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #if ENABLE_FEATURE_LS_COLOR | |
| # define show_color (G.show_color ) | |
| @@ -625,7 +625,7 @@ struct globals { | |
| /* Current position, to know when to wrap */ | |
| unsigned current_col; | |
| char buf[10]; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { \ | |
| G.device_name = bb_msg_standard_input; \ | |
| @@ -35,7 +35,7 @@ static const struct suffix_mult tail_suffixes[] = { | |
| struct globals { | |
| bool status; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| static void tail_xprint_header(const char *fmt, const char *filename) | |
| @@ -36,7 +36,7 @@ struct globals { | |
| char **names; | |
| int cur; | |
| char *cmd[1]; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define names (G.names) | |
| #define cur (G.cur ) | |
| @@ -96,7 +96,7 @@ struct globals { | |
| char *pidfile; | |
| int user_id; | |
| smallint signal_nr; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define found (G.found ) | |
| #define userspec (G.userspec ) | |
| @@ -444,7 +444,7 @@ struct globals2 { | |
| /* biggest and least used members go last */ | |
| tsplitter fsplitter, rsplitter; | |
| - | }; |
| + | }; //FIX_ALIASING; - large code growth |
| #define G1 (ptr_to_globals[-1]) | |
| #define G (*(struct globals2 *)ptr_to_globals) | |
| /* For debug. nm --size-sort awk.o | grep -vi ' [tr] ' */ | |
| @@ -117,7 +117,7 @@ struct globals { | |
| int idx; /* Space used */ | |
| int len; /* Space allocated */ | |
| } pipeline; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| void BUG_sed_globals_too_big(void); | |
| #define INIT_G() do { \ | |
| @@ -104,7 +104,7 @@ struct globals { | |
| action ***actions; | |
| bool need_print; | |
| recurse_flags_t recurse_flags; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { \ | |
| struct G_sizecheck { \ | |
| @@ -111,7 +111,7 @@ struct globals { | |
| /* globals used internally */ | |
| llist_t *pattern_head; /* growable list of patterns to match */ | |
| const char *cur_file; /* the current file we are reading */ | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { \ | |
| struct G_sizecheck { \ | |
| @@ -100,6 +100,13 @@ | |
| # define EXTERNALLY_VISIBLE | |
| #endif | |
| + | /* At 4.4 gcc become much more anal about this, need to use "aliased" types */ |
| + | #if __GNUC_PREREQ(4,4) |
| + | # define FIX_ALIASING __attribute__((__may_alias__)) |
| + | #else |
| + | # define FIX_ALIASING |
| + | #endif |
| + | |
| /* We use __extension__ in some places to suppress -pedantic warnings | |
| about GCC extensions. This feature didn't work properly before | |
| gcc 2.8. */ | |
| @@ -94,7 +94,7 @@ struct globals { | |
| char *env_var_user; | |
| char *env_var_home; | |
| #endif | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define LogLevel (G.LogLevel ) | |
| #define LogFile (G.LogFile ) | |
| @@ -13,7 +13,7 @@ struct globals { | |
| unsigned pointer; | |
| unsigned base; | |
| double stack[1]; | |
| - | }; |
| + | } FIX_ALIASING; |
| enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(double) }; | |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define pointer (G.pointer ) | |
| @@ -315,7 +315,7 @@ struct globals { | |
| #ifdef DO_FLUSHCACHE | |
| unsigned char flushcache[4] = { WIN_FLUSHCACHE, 0, 0, 0 }; | |
| #endif | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| struct BUG_G_too_big { | |
| char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; | |
| @@ -70,7 +70,7 @@ struct globals { | |
| int num_unresolved_deps; | |
| /* bool. "Did we have 'symbol:FOO' requested on cmdline?" */ | |
| smallint need_symbols; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { } while (0) | |
| @@ -3203,6 +3203,7 @@ static int obj_create_image(struct obj_file *f, char *image) | |
| static struct obj_file *obj_load(char *image, size_t image_size, int loadprogbits) | |
| { | |
| + | typedef uint32_t aliased_uint32_t FIX_ALIASING; |
| #if BB_LITTLE_ENDIAN | |
| # define ELFMAG_U32 ((uint32_t)(ELFMAG0 + 0x100 * (ELFMAG1 + (0x100 * (ELFMAG2 + 0x100 * ELFMAG3))))) | |
| #else | |
| @@ -3224,7 +3225,7 @@ static struct obj_file *obj_load(char *image, size_t image_size, int loadprogbit | |
| bb_error_msg_and_die("error while loading ELF header"); | |
| memcpy(&f->header, image, sizeof(f->header)); | |
| - | if (*(uint32_t*)(&f->header.e_ident) != ELFMAG_U32) { |
| + | if (*(aliased_uint32_t*)(&f->header.e_ident) != ELFMAG_U32) { |
| bb_error_msg_and_die("not an ELF file"); | |
| } | |
| if (f->header.e_ident[EI_CLASS] != ELFCLASSM | |
| @@ -51,7 +51,7 @@ struct globals { | |
| const char *device; /* current device */ | |
| smallint hw_set; /* flag if hw-type was set (-H) */ | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define ap (G.ap ) | |
| #define hw (G.hw ) | |
| @@ -45,7 +45,7 @@ struct globals { | |
| unsigned received; | |
| unsigned brd_recv; | |
| unsigned req_recv; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define src (G.src ) | |
| #define dst (G.dst ) | |
| @@ -106,7 +106,7 @@ struct globals { | |
| /* We need these aligned to uint32_t */ | |
| char msg_ok [(sizeof("NNN " MSG_OK ) + 3) & 0xfffc]; | |
| char msg_err[(sizeof("NNN " MSG_ERR) + 3) & 0xfffc]; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { \ | |
| /* Moved to main */ \ | |
| @@ -23,7 +23,7 @@ struct globals { | |
| int verbose_flag; | |
| int do_continue; | |
| char buf[1]; /* actually [BUFSZ] */ | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| enum { BUFSZ = COMMON_BUFSIZE - offsetof(struct globals, buf) }; | |
| struct BUG_G_too_big { | |
| @@ -106,7 +106,7 @@ enum { | |
| struct globals { | |
| char **my_environ; | |
| const char *startup_PATH; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { } while (0) | |
| @@ -313,7 +313,7 @@ struct globals { | |
| fd_set allsock; | |
| /* Used in next_line(), and as scratch read buffer */ | |
| char line[256]; /* _at least_ 256, see LINE_SIZE */ | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| enum { LINE_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line) }; | |
| struct BUG_G_too_big { | |
| @@ -263,7 +263,7 @@ struct globals { | |
| #endif | |
| } pingaddr; | |
| char rcvd_tbl[MAX_DUP_CHK / 8]; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define pingsock (G.pingsock ) | |
| #define if_index (G.if_index ) | |
| @@ -20,7 +20,7 @@ struct globals { | |
| int handle; | |
| int saved_disc; | |
| struct termios saved_state; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define handle (G.handle ) | |
| #define saved_disc (G.saved_disc ) | |
| @@ -43,8 +43,7 @@ struct globals { | |
| __u32 filter_parent; | |
| __u32 filter_prio; | |
| __u32 filter_proto; | |
| - | }; |
| - | |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define filter_ifindex (G.filter_ifindex) | |
| #define filter_qdisc (G.filter_qdisc) | |
| @@ -50,7 +50,7 @@ struct globals { | |
| unsigned cmax; | |
| char **env_cur; | |
| char *env_var[1]; /* actually bigger */ | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define verbose (G.verbose ) | |
| #define max_per_host (G.max_per_host) | |
| @@ -75,7 +75,7 @@ struct globals { | |
| char iacbuf[IACBUFSIZE]; | |
| struct termios termios_def; | |
| struct termios termios_raw; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { \ | |
| struct G_sizecheck { \ | |
| @@ -60,7 +60,7 @@ struct globals { | |
| const char *loginpath; | |
| const char *issuefile; | |
| int maxfd; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { \ | |
| G.loginpath = "/bin/login"; \ | |
| @@ -90,7 +90,7 @@ struct globals { | |
| const char *file; | |
| bb_progress_t pmt; | |
| #endif | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| struct BUG_G_too_big { | |
| char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; | |
| @@ -30,7 +30,7 @@ struct globals { | |
| #endif | |
| smallint chunked; /* chunked transfer encoding */ | |
| smallint got_clen; /* got content-length: from server */ | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| struct BUG_G_too_big { | |
| char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; | |
| @@ -77,7 +77,7 @@ enum { | |
| struct globals { | |
| struct sockaddr saddr; | |
| struct ether_addr eth_addr; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define saddr (G.saddr ) | |
| #define eth_addr (G.eth_addr) | |
| @@ -49,7 +49,7 @@ struct globals { | |
| unsigned long long seconds_since_boot; | |
| #endif | |
| char default_o[sizeof(DEFAULT_O_STR)]; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define out (G.out ) | |
| #define out_cnt (G.out_cnt ) | |
| @@ -100,10 +100,8 @@ struct globals { | |
| int num_cpus; | |
| #endif | |
| char line_buf[80]; | |
| - | }; |
| - | |
| + | }; //FIX_ALIASING; - large code growth |
| enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) }; | |
| - | |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define INIT_G() do { \ | |
| struct G_sizecheck { \ | |
| @@ -95,7 +95,7 @@ struct globals { | |
| struct fd_pair logpipe; | |
| char *dir; | |
| struct svdir svd[2]; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define haslog (G.haslog ) | |
| #define sigterm (G.sigterm ) | |
| @@ -58,7 +58,7 @@ struct globals { | |
| struct pollfd pfd[1]; | |
| unsigned stamplog; | |
| #endif | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define sv (G.sv ) | |
| #define svdir (G.svdir ) | |
| @@ -165,7 +165,7 @@ struct globals { | |
| /* "Bernstein" time format: unix + 0x400000000000000aULL */ | |
| uint64_t tstart, tnow; | |
| svstatus_t svstatus; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define acts (G.acts ) | |
| #define service (G.service ) | |
| @@ -184,7 +184,7 @@ struct globals { | |
| sigset_t blocked_sigset; | |
| }; | |
| - | #define G (*(struct globals*)ptr_to_globals) |
| + | #define G (*ptr_to_globals) |
| #define dir (G.dir ) | |
| #define verbose (G.verbose ) | |
| #define linemax (G.linemax ) | |
| @@ -35,8 +35,7 @@ struct globals { | |
| dev_t dev_id; /* Device id where target file exists */ | |
| int nerr; | |
| struct edir excludeArray[MAX_EXCLUDES]; | |
| - | }; |
| - | |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| void BUG_setfiles_globals_too_big(void); | |
| #define INIT_G() do { \ | |
| @@ -34,7 +34,7 @@ struct globals { | |
| struct sembuf SMrup[1]; // {0, -1, IPC_NOWAIT | SEM_UNDO}, | |
| struct sembuf SMrdn[2]; // {1, 0}, {0, +1, SEM_UNDO} | |
| struct shbuf_ds *shbuf; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define SMrup (G.SMrup) | |
| #define SMrdn (G.SMrdn) | |
| @@ -157,7 +157,6 @@ struct globals { | |
| /* File-name data */ | |
| char current_name[MAX_DEPTH * MINIX_NAME_MAX]; | |
| }; | |
| - | |
| #define G (*ptr_to_globals) | |
| #if ENABLE_FEATURE_MINIX2 | |
| #define version2 (G.version2 ) | |
| @@ -64,7 +64,7 @@ | |
| struct globals { | |
| int root_major, root_minor; | |
| char *subsystem; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define root_major (G.root_major) | |
| #define root_minor (G.root_minor) | |
| @@ -22,7 +22,7 @@ struct globals { | |
| int cin_fileno; | |
| struct termios initial_settings; | |
| struct termios new_settings; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)bb_common_bufsiz1) | |
| #define INIT_G() ((void)0) | |
| #define initial_settings (G.initial_settings) | |
| @@ -268,7 +268,7 @@ struct globals { | |
| llist_t *fslist; | |
| char getmntent_buf[1]; | |
| - | }; |
| + | } FIX_ALIASING; |
| enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_buf) }; | |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define nfs_mount_version (G.nfs_mount_version) | |
| @@ -20,7 +20,7 @@ | |
| #if ENABLE_FEATURE_SWAPON_PRI | |
| struct globals { | |
| int flags; | |
| - | }; |
| + | } FIX_ALIASING; |
| #define G (*(struct globals*)&bb_common_bufsiz1) | |
| #define g_flags (G.flags) | |
| #else | |