#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
* 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;
#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
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)
#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);
}
* 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
* (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",
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 */ \
int slink_depth;
int du_depth;
dev_t dir_dev;
-};
+} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
/* 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 */
/* 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 )
/* 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; \
struct globals {
bool status;
-};
+} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
static void tail_xprint_header(const char *fmt, const char *filename)
char **names;
int cur;
char *cmd[1];
-};
+} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
#define names (G.names)
#define cur (G.cur )
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 )
/* 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] ' */
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 { \
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 { \
/* 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 { \
# 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. */
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 )
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 )
#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];
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)
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
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
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 )
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 )
/* 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 */ \
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 {
struct globals {
char **my_environ;
const char *startup_PATH;
-};
+} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { } while (0)
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 {
#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 )
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 )
__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)
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)
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 { \
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"; \
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];
#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];
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)
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 )
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 { \
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 )
struct pollfd pfd[1];
unsigned stamplog;
#endif
-};
+} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
#define sv (G.sv )
#define svdir (G.svdir )
/* "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 )
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 )
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 { \
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)
/* File-name data */
char current_name[MAX_DEPTH * MINIX_NAME_MAX];
};
-
#define G (*ptr_to_globals)
#if ENABLE_FEATURE_MINIX2
#define version2 (G.version2 )
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)
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)
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)
#if ENABLE_FEATURE_SWAPON_PRI
struct globals {
int flags;
-};
+} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
#define g_flags (G.flags)
#else