summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1e424a2)
Using DIM(a) added to h/mh.h
#define NMH_UNUSED(i) i
#endif
#define NMH_UNUSED(i) i
#endif
+/* DIM gives the number of elements in the one-dimensional array a. */
+#define DIM(a) (sizeof (a) / sizeof (*(a)))
+
/* LEN gives the strlen() of string constant s, excluding the
* terminating NUL. */
#define LEN(s) (sizeof (s) - 1)
/* LEN gives the strlen() of string constant s, excluding the
* terminating NUL. */
#define LEN(s) (sizeof (s) - 1)
{
int eindex = errno;
char buffer[BUFSIZ], errbuf[BUFSIZ], *err;
{
int eindex = errno;
char buffer[BUFSIZ], errbuf[BUFSIZ], *err;
- struct iovec iob[20], *iov;
+ struct iovec iob[10], *iov;
+ size_t niov;
#undef ADD_LITERAL
#undef ADD_VAR
#undef ADD_LITERAL
#undef ADD_VAR
+ niov = iov - iob;
+ assert(niov <= DIM(iob));
+
fflush (stdout);
fflush (stderr);
fflush (stdout);
fflush (stderr);
- if (writev (fileno (stderr), iob, iov - iob) < 0) {
+ if (writev(fileno(stderr), iob, niov) == -1) {
snprintf(buffer, sizeof buffer, "%s: write stderr failed: %d\n",
invo_name && *invo_name ? invo_name : "nmh", errno);
if (write(2, buffer, strlen(buffer)) == -1) {
snprintf(buffer, sizeof buffer, "%s: write stderr failed: %d\n",
invo_name && *invo_name ? invo_name : "nmh", errno);
if (write(2, buffer, strlen(buffer)) == -1) {