aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-05-10 20:10:13 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-05-10 20:10:13 +1000
commitd2a9ddeb6cc58284996fbc5367877c99fee8914e (patch)
tree187cadb382d0336bbc529cc7ca9e3d1ccd680213
parent1fa419fb3c7ef91e878398bb0388854d27d7bd8f (diff)
downloadbusybox-w32-old.tar.gz
busybox-w32-old.tar.bz2
busybox-w32-old.zip
general warning cleanupold
-rw-r--r--archival/Config.in14
-rw-r--r--archival/gzip.c6
-rw-r--r--include/libbb.h3
-rw-r--r--include/mingw.h13
-rw-r--r--libbb/Kbuild13
-rw-r--r--libbb/git.c31
-rw-r--r--libbb/git.h5
-rw-r--r--libbb/lineedit.c2
-rw-r--r--libbb/mingw.c5
-rw-r--r--libbb/regex.c2
-rw-r--r--libbb/strbuf.c11
-rw-r--r--libbb/strbuf_file.c4
-rw-r--r--libbb/termios.c2
-rw-r--r--libbb/usage.c81
-rw-r--r--networking/wget.c1
-rw-r--r--shell/ash_mingw.c4
16 files changed, 83 insertions, 114 deletions
diff --git a/archival/Config.in b/archival/Config.in
index f21509271..22f985ac0 100644
--- a/archival/Config.in
+++ b/archival/Config.in
@@ -154,7 +154,7 @@ config FEATURE_TAR_CREATE
154config FEATURE_TAR_BZIP2 154config FEATURE_TAR_BZIP2
155 bool "Enable -j option to handle .tar.bz2 files" 155 bool "Enable -j option to handle .tar.bz2 files"
156 default n 156 default n
157 depends on TAR 157 depends on TAR && !MINGW32 # open_transformer.c
158 help 158 help
159 If you enable this option you'll be able to extract 159 If you enable this option you'll be able to extract
160 archives compressed with bzip2. 160 archives compressed with bzip2.
@@ -162,7 +162,7 @@ config FEATURE_TAR_BZIP2
162config FEATURE_TAR_LZMA 162config FEATURE_TAR_LZMA
163 bool "Enable -a option to handle .tar.lzma files" 163 bool "Enable -a option to handle .tar.lzma files"
164 default n 164 default n
165 depends on TAR 165 depends on TAR && !MINGW32 # open_transformer.c
166 help 166 help
167 If you enable this option you'll be able to extract 167 If you enable this option you'll be able to extract
168 archives compressed with lzma. 168 archives compressed with lzma.
@@ -178,7 +178,7 @@ config FEATURE_TAR_FROM
178config FEATURE_TAR_GZIP 178config FEATURE_TAR_GZIP
179 bool "Enable -z option" 179 bool "Enable -z option"
180 default y 180 default y
181 depends on TAR 181 depends on TAR && !MINGW32 # open_transformer.c
182 help 182 help
183 If you enable this option tar will be able to call gzip, 183 If you enable this option tar will be able to call gzip,
184 when creating or extracting tar gziped archives. 184 when creating or extracting tar gziped archives.
@@ -186,7 +186,7 @@ config FEATURE_TAR_GZIP
186config FEATURE_TAR_COMPRESS 186config FEATURE_TAR_COMPRESS
187 bool "Enable -Z option" 187 bool "Enable -Z option"
188 default n 188 default n
189 depends on TAR 189 depends on TAR && !MINGW32 # open_transformer.c
190 help 190 help
191 If you enable this option tar will be able to call uncompress, 191 If you enable this option tar will be able to call uncompress,
192 when extracting .tar.Z archives. 192 when extracting .tar.Z archives.
@@ -271,7 +271,7 @@ comment "Common options for dpkg and dpkg_deb"
271config FEATURE_DEB_TAR_GZ 271config FEATURE_DEB_TAR_GZ
272 bool "gzip debian packages (normal)" 272 bool "gzip debian packages (normal)"
273 default y if DPKG || DPKG_DEB 273 default y if DPKG || DPKG_DEB
274 depends on DPKG || DPKG_DEB 274 depends on (DPKG || DPKG_DEB) && !MINGW32 # open_transformer.c
275 help 275 help
276 This is the default compression method inside the debian ar file. 276 This is the default compression method inside the debian ar file.
277 277
@@ -280,7 +280,7 @@ config FEATURE_DEB_TAR_GZ
280config FEATURE_DEB_TAR_BZ2 280config FEATURE_DEB_TAR_BZ2
281 bool "bzip2 debian packages" 281 bool "bzip2 debian packages"
282 default n 282 default n
283 depends on DPKG || DPKG_DEB 283 depends on (DPKG || DPKG_DEB) && !MINGW32 # open_transformer.c
284 help 284 help
285 This allows dpkg and dpkg-deb to extract deb's that are compressed internally 285 This allows dpkg and dpkg-deb to extract deb's that are compressed internally
286 with bzip2 instead of gzip. 286 with bzip2 instead of gzip.
@@ -291,7 +291,7 @@ config FEATURE_DEB_TAR_BZ2
291config FEATURE_DEB_TAR_LZMA 291config FEATURE_DEB_TAR_LZMA
292 bool "lzma debian packages" 292 bool "lzma debian packages"
293 default n 293 default n
294 depends on DPKG || DPKG_DEB 294 depends on (DPKG || DPKG_DEB) && !MINGW32 # open_transformer.c
295 help 295 help
296 This allows dpkg and dpkg-deb to extract deb's that are compressed 296 This allows dpkg and dpkg-deb to extract deb's that are compressed
297 internally with lzma instead of gzip. 297 internally with lzma instead of gzip.
diff --git a/archival/gzip.c b/archival/gzip.c
index fdf2a794c..14d1ef2b0 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -1589,6 +1589,9 @@ static void compress_block(ct_data * ltree, ct_data * dtree)
1589 * trees or store, and output the encoded block to the zip file. This function 1589 * trees or store, and output the encoded block to the zip file. This function
1590 * returns the total compressed length for the file so far. 1590 * returns the total compressed length for the file so far.
1591 */ 1591 */
1592#ifdef __MINGW32__
1593#define eof eof_
1594#endif
1592static ulg flush_block(char *buf, ulg stored_len, int eof) 1595static ulg flush_block(char *buf, ulg stored_len, int eof)
1593{ 1596{
1594 ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ 1597 ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
@@ -1672,6 +1675,9 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
1672 1675
1673 return G2.compressed_len >> 3; 1676 return G2.compressed_len >> 3;
1674} 1677}
1678#ifdef __MINGW32__
1679#undef eof
1680#endif
1675 1681
1676 1682
1677/* =========================================================================== 1683/* ===========================================================================
diff --git a/include/libbb.h b/include/libbb.h
index ea02a9978..ce90a11c7 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -410,6 +410,7 @@ extern void *xzalloc(size_t size);
410extern void *xrealloc(void *old, size_t size); 410extern void *xrealloc(void *old, size_t size);
411 411
412extern ssize_t safe_read(int fd, void *buf, size_t count); 412extern ssize_t safe_read(int fd, void *buf, size_t count);
413extern void xread(int fd, void *buf, size_t count);
413extern ssize_t full_read(int fd, void *buf, size_t count); 414extern ssize_t full_read(int fd, void *buf, size_t count);
414extern unsigned char xread_char(int fd); 415extern unsigned char xread_char(int fd);
415extern char *reads(int fd, char *buf, size_t count); 416extern char *reads(int fd, char *buf, size_t count);
@@ -419,6 +420,7 @@ extern void *xmalloc_open_read_close(const char *filename, size_t *sizep);
419 420
420#define safe_write(fd, buf, count) bb_safe_write(fd, buf, count) 421#define safe_write(fd, buf, count) bb_safe_write(fd, buf, count)
421extern ssize_t safe_write(int fd, const void *buf, size_t count); 422extern ssize_t safe_write(int fd, const void *buf, size_t count);
423extern void xwrite(int fd, const void *buf, size_t count);
422extern ssize_t full_write(int fd, const void *buf, size_t count); 424extern ssize_t full_write(int fd, const void *buf, size_t count);
423 425
424/* Reads and prints to stdout till eof, then closes FILE. Exits on error: */ 426/* Reads and prints to stdout till eof, then closes FILE. Exits on error: */
@@ -442,6 +444,7 @@ extern FILE *fopen_or_warn_stdin(const char *filename);
442 444
443/* Convert each alpha char in str to lower-case */ 445/* Convert each alpha char in str to lower-case */
444extern char* str_tolower(char *str); 446extern char* str_tolower(char *str);
447extern char* xstrndup(const char *s, int n);
445 448
446char *utoa(unsigned n); 449char *utoa(unsigned n);
447#ifdef __MINGW32__ 450#ifdef __MINGW32__
diff --git a/include/mingw.h b/include/mingw.h
index 500308947..1c3728ee4 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -83,8 +83,10 @@ static inline int symlink(const char *oldpath, const char *newpath)
83{ errno = ENOSYS; return -1; } 83{ errno = ENOSYS; return -1; }
84static inline int fchmod(int fildes, mode_t mode) 84static inline int fchmod(int fildes, mode_t mode)
85{ errno = ENOSYS; return -1; } 85{ errno = ENOSYS; return -1; }
86/*
86static inline int fork(void) 87static inline int fork(void)
87{ errno = ENOSYS; return -1; } 88{ errno = ENOSYS; return -1; }
89*/
88static inline unsigned int alarm(unsigned int seconds) 90static inline unsigned int alarm(unsigned int seconds)
89{ return 0; } 91{ return 0; }
90static inline int fsync(int fd) 92static inline int fsync(int fd)
@@ -93,7 +95,7 @@ static inline int getppid(void)
93{ return 1; } 95{ return 1; }
94static inline void sync(void) 96static inline void sync(void)
95{} 97{}
96static inline int getuid() 98static inline int getuid(void)
97{ return 1; } 99{ return 1; }
98static inline struct passwd *getpwnam(const char *name) 100static inline struct passwd *getpwnam(const char *name)
99{ return NULL; } 101{ return NULL; }
@@ -148,6 +150,13 @@ int setitimer(int type, struct itimerval *in, struct itimerval *out);
148int sigaction(int sig, struct sigaction *in, struct sigaction *out); 150int sigaction(int sig, struct sigaction *in, struct sigaction *out);
149int link(const char *oldpath, const char *newpath); 151int link(const char *oldpath, const char *newpath);
150time_t tm_to_time_t(const struct tm *tm); 152time_t tm_to_time_t(const struct tm *tm);
153char *strsep(char **stringp, const char *delim);
154char *strptime(const char *s, const char *format, struct tm *tm);
155void unsetenv(const char *env);
156char *realpath(const char *path, char *resolved_path);
157int fdprintf(int fd, const char *format, ...);
158int setenv(const char *name, const char *value, int replace);
159size_t strlcpy(char *dest, const char *src, size_t size);
151 160
152/* 161/*
153 * replacements of existing functions 162 * replacements of existing functions
@@ -251,7 +260,7 @@ char **copy_environ(void);
251void free_environ(char **env); 260void free_environ(char **env);
252char **env_setenv(char **env, const char *name); 261char **env_setenv(char **env, const char *name);
253 262
254const char *get_busybox_exec_path(); 263const char *get_busybox_exec_path(void);
255/* 264/*
256 * A replacement of main() that ensures that argv[0] has a path 265 * A replacement of main() that ensures that argv[0] has a path
257 */ 266 */
diff --git a/libbb/Kbuild b/libbb/Kbuild
index b3560bd0b..1ef67a8b7 100644
--- a/libbb/Kbuild
+++ b/libbb/Kbuild
@@ -13,11 +13,17 @@ lib-y += change_identity.o
13lib-y += create_icmp6_socket.o 13lib-y += create_icmp6_socket.o
14lib-y += create_icmp_socket.o 14lib-y += create_icmp_socket.o
15lib-y += device_open.o 15lib-y += device_open.o
16lib-y += get_console.o
16lib-y += inet_common.o 17lib-y += inet_common.o
18lib-y += inode_hash.o
17lib-y += kernel_version.o 19lib-y += kernel_version.o
18lib-y += login.o 20lib-y += login.o
19lib-y += makedev.o 21lib-y += makedev.o
20lib-y += match_fstype.o 22lib-y += match_fstype.o
23lib-y += obscure.o
24lib-y += procps.o
25lib-y += restricted_shell.o
26lib-y += run_shell.o
21lib-y += setup_environment.o 27lib-y += setup_environment.o
22lib-y += speed_table.o 28lib-y += speed_table.o
23lib-y += vfork_daemon_rexec.o 29lib-y += vfork_daemon_rexec.o
@@ -46,7 +52,6 @@ lib-y += fgets_str.o
46lib-y += find_pid_by_name.o 52lib-y += find_pid_by_name.o
47lib-y += find_root_device.o 53lib-y += find_root_device.o
48lib-y += full_write.o 54lib-y += full_write.o
49lib-y += get_console.o
50lib-y += get_last_path_component.o 55lib-y += get_last_path_component.o
51lib-y += get_line_from_file.o 56lib-y += get_line_from_file.o
52lib-y += getopt32.o 57lib-y += getopt32.o
@@ -54,7 +59,6 @@ lib-y += herror_msg.o
54lib-y += herror_msg_and_die.o 59lib-y += herror_msg_and_die.o
55lib-y += human_readable.o 60lib-y += human_readable.o
56lib-y += info_msg.o 61lib-y += info_msg.o
57lib-y += inode_hash.o
58lib-y += isdirectory.o 62lib-y += isdirectory.o
59lib-y += last_char_is.o 63lib-y += last_char_is.o
60lib-y += lineedit.o 64lib-y += lineedit.o
@@ -64,7 +68,6 @@ lib-y += md5.o
64lib-y += messages.o 68lib-y += messages.o
65lib-y += mode_string.o 69lib-y += mode_string.o
66lib-y += mtab_file.o 70lib-y += mtab_file.o
67lib-y += obscure.o
68lib-y += parse_mode.o 71lib-y += parse_mode.o
69lib-y += perror_msg.o 72lib-y += perror_msg.o
70lib-y += perror_msg_and_die.o 73lib-y += perror_msg_and_die.o
@@ -72,12 +75,9 @@ lib-y += perror_nomsg.o
72lib-y += perror_nomsg_and_die.o 75lib-y += perror_nomsg_and_die.o
73lib-y += pidfile.o 76lib-y += pidfile.o
74lib-y += process_escape_sequence.o 77lib-y += process_escape_sequence.o
75lib-y += procps.o
76lib-y += read.o 78lib-y += read.o
77lib-y += recursive_action.o 79lib-y += recursive_action.o
78lib-y += remove_file.o 80lib-y += remove_file.o
79lib-y += restricted_shell.o
80lib-y += run_shell.o
81lib-y += safe_strncpy.o 81lib-y += safe_strncpy.o
82lib-y += safe_write.o 82lib-y += safe_write.o
83lib-y += sha1.o 83lib-y += sha1.o
@@ -140,6 +140,5 @@ lib-$(CONFIG_MINGW32) += strbuf_file.o
140lib-$(CONFIG_MINGW32) += strlcpy.o 140lib-$(CONFIG_MINGW32) += strlcpy.o
141lib-$(CONFIG_MINGW32) += termios.o 141lib-$(CONFIG_MINGW32) += termios.o
142lib-$(CONFIG_MINGW32) += trace.o 142lib-$(CONFIG_MINGW32) += trace.o
143lib-$(CONFIG_MINGW32) += usage.o
144lib-$(CONFIG_MINGW32) += winansi.o 143lib-$(CONFIG_MINGW32) += winansi.o
145lib-$(CONFIG_MINGW32) += write_or_die.o 144lib-$(CONFIG_MINGW32) += write_or_die.o
diff --git a/libbb/git.c b/libbb/git.c
index 3ca8a9424..668f8c118 100644
--- a/libbb/git.c
+++ b/libbb/git.c
@@ -1,13 +1,42 @@
1#include "libbb.h" 1#include "libbb.h"
2#include "git.h" 2#include "git.h"
3 3
4#define die bb_error_msg_and_die
5
6/*
7 * xwrite() is the same a write(), but it automatically restarts write()
8 * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT
9 * GUARANTEE that "len" bytes is written even if the operation is successful.
10 */
11ssize_t _xwrite(int fd, const void *buf, size_t len)
12{
13 ssize_t nr;
14 while (1) {
15 nr = write(fd, buf, len);
16 if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
17 continue;
18 return nr;
19 }
20}
21
22ssize_t _xread(int fd, void *buf, size_t len)
23{
24 ssize_t nr;
25 while (1) {
26 nr = read(fd, buf, len);
27 if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
28 continue;
29 return nr;
30 }
31}
32
4ssize_t write_in_full(int fd, const void *buf, size_t count) 33ssize_t write_in_full(int fd, const void *buf, size_t count)
5{ 34{
6 const char *p = buf; 35 const char *p = buf;
7 ssize_t total = 0; 36 ssize_t total = 0;
8 37
9 while (count > 0) { 38 while (count > 0) {
10 ssize_t written = xwrite(fd, p, count); 39 ssize_t written = _xwrite(fd, p, count);
11 if (written < 0) 40 if (written < 0)
12 return -1; 41 return -1;
13 if (!written) { 42 if (!written) {
diff --git a/libbb/git.h b/libbb/git.h
index 3274af34d..07ef93bf4 100644
--- a/libbb/git.h
+++ b/libbb/git.h
@@ -1,4 +1,7 @@
1ssize_t write_in_full(int fd, const void *buf, size_t count); 1ssize_t write_in_full(int fd, const void *buf, size_t count);
2void *xcalloc(size_t nmemb, size_t size);
3ssize_t _xwrite(int fd, const void *buf, size_t len);
4ssize_t _xread(int fd, void *buf, size_t len);
2 5
3#define alloc_nr(x) (((x)+16)*3/2) 6#define alloc_nr(x) (((x)+16)*3/2)
4 7
@@ -19,3 +22,5 @@ static inline int is_absolute_path(const char *path)
19} 22}
20 23
21#define NORETURN ATTRIBUTE_NORETURN 24#define NORETURN ATTRIBUTE_NORETURN
25#define die bb_error_msg_and_die
26#define error(...) fprintf(stderr, __VA_ARGS__)
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index e56dd20b0..a4b0ff045 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -170,7 +170,7 @@ static void input_backward(unsigned num)
170 if (cmdedit_x >= num) { 170 if (cmdedit_x >= num) {
171 cmdedit_x -= num; 171 cmdedit_x -= num;
172 if (num <= 4) { 172 if (num <= 4) {
173 printf("\b\b\b\b" + (4-num)); 173 printf("%s", "\b\b\b\b" + (4-num)); /* "%s" to stop mingw warning */
174 return; 174 return;
175 } 175 }
176 printf("\033[%uD", num); 176 printf("\033[%uD", num);
diff --git a/libbb/mingw.c b/libbb/mingw.c
index aa1417acf..ab582215b 100644
--- a/libbb/mingw.c
+++ b/libbb/mingw.c
@@ -2,6 +2,7 @@
2#include "win32.h" 2#include "win32.h"
3#include "strbuf.h" 3#include "strbuf.h"
4#include "run-command.h" 4#include "run-command.h"
5#include "git.h"
5 6
6unsigned int _CRT_fmode = _O_BINARY; 7unsigned int _CRT_fmode = _O_BINARY;
7 8
@@ -131,13 +132,15 @@ int mingw_open (const char *filename, int oflags, ...)
131{ 132{
132 va_list args; 133 va_list args;
133 unsigned mode; 134 unsigned mode;
135 int fd;
136
134 va_start(args, oflags); 137 va_start(args, oflags);
135 mode = va_arg(args, int); 138 mode = va_arg(args, int);
136 va_end(args); 139 va_end(args);
137 140
138 if (!strcmp(filename, "/dev/null")) 141 if (!strcmp(filename, "/dev/null"))
139 filename = "nul"; 142 filename = "nul";
140 int fd = open(filename, oflags, mode); 143 fd = open(filename, oflags, mode);
141 if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) { 144 if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
142 DWORD attrs = GetFileAttributes(filename); 145 DWORD attrs = GetFileAttributes(filename);
143 if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) 146 if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
diff --git a/libbb/regex.c b/libbb/regex.c
index 87b33e466..2cca16934 100644
--- a/libbb/regex.c
+++ b/libbb/regex.c
@@ -24,7 +24,9 @@
24 #pragma alloca 24 #pragma alloca
25#endif 25#endif
26 26
27#ifndef _GNU_SOURCE
27#define _GNU_SOURCE 28#define _GNU_SOURCE
29#endif
28 30
29/* We need this for `regex.h', and perhaps for the Emacs include files. */ 31/* We need this for `regex.h', and perhaps for the Emacs include files. */
30#include <sys/types.h> 32#include <sys/types.h>
diff --git a/libbb/strbuf.c b/libbb/strbuf.c
index d98b0fd41..98659d448 100644
--- a/libbb/strbuf.c
+++ b/libbb/strbuf.c
@@ -2,15 +2,6 @@
2#include "strbuf.h" 2#include "strbuf.h"
3#include "git.h" 3#include "git.h"
4 4
5int prefixcmp(const char *str, const char *prefix)
6{
7 for (; ; str++, prefix++)
8 if (!*prefix)
9 return 0;
10 else if (*str != *prefix)
11 return (unsigned char)*prefix - (unsigned char)*str;
12}
13
14/* 5/*
15 * Used as the default ->buf value, so that people can always assume 6 * Used as the default ->buf value, so that people can always assume
16 * buf is non NULL and ->buf is NUL terminated even for a freshly 7 * buf is non NULL and ->buf is NUL terminated even for a freshly
@@ -275,7 +266,7 @@ ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint)
275 for (;;) { 266 for (;;) {
276 ssize_t cnt; 267 ssize_t cnt;
277 268
278 cnt = xread(fd, sb->buf + sb->len, sb->alloc - sb->len - 1); 269 cnt = _xread(fd, sb->buf + sb->len, sb->alloc - sb->len - 1);
279 if (cnt < 0) { 270 if (cnt < 0) {
280 if (oldalloc == 0) 271 if (oldalloc == 0)
281 strbuf_release(sb); 272 strbuf_release(sb);
diff --git a/libbb/strbuf_file.c b/libbb/strbuf_file.c
index fb2ba7966..cdacf5344 100644
--- a/libbb/strbuf_file.c
+++ b/libbb/strbuf_file.c
@@ -31,14 +31,14 @@ int sfprintf(struct strbuf_file *sf, const char *fmt, ...)
31 len = vsnprintf(sb.buf + sb.len, sb.alloc - sb.len, fmt, ap); 31 len = vsnprintf(sb.buf + sb.len, sb.alloc - sb.len, fmt, ap);
32 va_end(ap); 32 va_end(ap);
33 if (len < 0) 33 if (len < 0)
34 die("your vsnprintf is broken"); 34 bb_error_msg_and_die("your vsnprintf is broken");
35 if (len > strbuf_avail(&sb)) { 35 if (len > strbuf_avail(&sb)) {
36 strbuf_grow(&sb, len); 36 strbuf_grow(&sb, len);
37 va_start(ap, fmt); 37 va_start(ap, fmt);
38 len = vsnprintf(sb.buf + sb.len, sb.alloc - sb.len, fmt, ap); 38 len = vsnprintf(sb.buf + sb.len, sb.alloc - sb.len, fmt, ap);
39 va_end(ap); 39 va_end(ap);
40 if (len > strbuf_avail(&sb)) { 40 if (len > strbuf_avail(&sb)) {
41 die("this should not happen, your snprintf is broken"); 41 bb_error_msg_and_die("this should not happen, your snprintf is broken");
42 } 42 }
43 } 43 }
44 strbuf_setlen(&sb, sb.len + len); 44 strbuf_setlen(&sb, sb.len + len);
diff --git a/libbb/termios.c b/libbb/termios.c
index 1291bf785..04eee7ced 100644
--- a/libbb/termios.c
+++ b/libbb/termios.c
@@ -260,7 +260,7 @@ int wincon_read(int fd, char *buf, int size)
260 static int initialized = 0; 260 static int initialized = 0;
261 261
262 if (fd != 0) 262 if (fd != 0)
263 die("wincon_read is for stdin only"); 263 bb_error_msg_and_die("wincon_read is for stdin only");
264 if (cin == INVALID_HANDLE_VALUE || is_cygwin_tty(fd)) 264 if (cin == INVALID_HANDLE_VALUE || is_cygwin_tty(fd))
265 return safe_read(fd, buf, size); 265 return safe_read(fd, buf, size);
266 if (!initialized) { 266 if (!initialized) {
diff --git a/libbb/usage.c b/libbb/usage.c
deleted file mode 100644
index 86bf68e21..000000000
--- a/libbb/usage.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * GIT - The information manager from hell
3 *
4 * Copyright (C) Linus Torvalds, 2005
5 */
6#include "libbb.h"
7#include "git.h"
8
9static void report(const char *prefix, const char *err, va_list params)
10{
11 char msg[1024];
12 vsnprintf(msg, sizeof(msg), err, params);
13 fprintf(stderr, "%s%s\n", prefix, msg);
14}
15
16static NORETURN void usage_builtin(const char *err)
17{
18 fprintf(stderr, "usage: %s\n", err);
19 exit(129);
20}
21
22static NORETURN void die_builtin(const char *err, va_list params)
23{
24 report("fatal: ", err, params);
25 exit(128);
26}
27
28static void error_builtin(const char *err, va_list params)
29{
30 report("error: ", err, params);
31}
32
33static void warn_builtin(const char *warn, va_list params)
34{
35 report("warning: ", warn, params);
36}
37
38/* If we are in a dlopen()ed .so write to a global variable would segfault
39 * (ugh), so keep things static. */
40static void (*usage_routine)(const char *err) NORETURN = usage_builtin;
41static void (*die_routine)(const char *err, va_list params) NORETURN = die_builtin;
42static void (*error_routine)(const char *err, va_list params) = error_builtin;
43static void (*warn_routine)(const char *err, va_list params) = warn_builtin;
44
45void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN)
46{
47 die_routine = routine;
48}
49
50void usage(const char *err)
51{
52 usage_routine(err);
53}
54
55void die(const char *err, ...)
56{
57 va_list params;
58
59 va_start(params, err);
60 die_routine(err, params);
61 va_end(params);
62}
63
64int error(const char *err, ...)
65{
66 va_list params;
67
68 va_start(params, err);
69 error_routine(err, params);
70 va_end(params);
71 return -1;
72}
73
74void warning(const char *warn, ...)
75{
76 va_list params;
77
78 va_start(params, warn);
79 warn_routine(warn, params);
80 va_end(params);
81}
diff --git a/networking/wget.c b/networking/wget.c
index 8752a6bd2..d6f76c8af 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -670,6 +670,7 @@ static int ftpcmd(const char *s1, const char *s2, FILE *fp, char *buf)
670#ifdef __MINGW32__ 670#ifdef __MINGW32__
671 671
672/* from include/mingw.h */ 672/* from include/mingw.h */
673#undef fprintf /* winansi.c */
673#define fprintf(...) winansi_fprintf(__VA_ARGS__) 674#define fprintf(...) winansi_fprintf(__VA_ARGS__)
674 675
675/* Source: uclibc */ 676/* Source: uclibc */
diff --git a/shell/ash_mingw.c b/shell/ash_mingw.c
index a5295532d..a39919439 100644
--- a/shell/ash_mingw.c
+++ b/shell/ash_mingw.c
@@ -1,3 +1,5 @@
1#include "git.h"
2
1extern void trace_printf(const char *format, ...); 3extern void trace_printf(const char *format, ...);
2extern void trace_argv_printf(const char **argv, const char *format, ...); 4extern void trace_argv_printf(const char **argv, const char *format, ...);
3 5
@@ -18,7 +20,7 @@ static union node *node_recv(int fd);
18static inline void 20static inline void
19ser_read(int fd, void *buf, size_t len) 21ser_read(int fd, void *buf, size_t len)
20{ 22{
21 if (xread(fd, buf, len) != len) 23 if (_xread(fd, buf, len) != len)
22 die("Corrupted"); 24 die("Corrupted");
23} 25}
24 26