Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r1586 - trunk: . fsvs fsvs/src fsvs/src/dox fsvs/tests

fsvs
Discussion topic

Back to topic list

svn commit: r1586 - trunk: . fsvs fsvs/src fsvs/src/dox fsvs/tests

Author pmarek
Full name P.Marek
Date 2008-04-03 22:14:35 PDT
Message Author: pmarek
Date: 2008-04-03 22:14:34-0700
New Revision: 1586

Modified:
   trunk/ (props changed)
   trunk/fsvs/CHANGES
   trunk/fsvs/src/cp_mv.c
   trunk/fsvs/src/diff.c
   trunk/fsvs/src/dox/dev.dox
   trunk/fsvs/src/fsvs.c
   trunk/fsvs/src/global.h
   trunk/fsvs/src/helper.c
   trunk/fsvs/src/log.c
   trunk/fsvs/src/status.c
   trunk/fsvs/src/url.c
   trunk/fsvs/src/warnings.c
   trunk/fsvs/tests/018_various

Log:
Handling of SIGPIPE, most important for status.


Modified: trunk/fsvs/CHANGES
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/CHANGES​?view=diff&rev=1​586&p1=trunk/fsv​s/CHANGES&p2=tru​nk/fsvs/CHANGES&​r1=1585&r2=1586
====================​====================​====================​==================
--- trunk/fsvs/CHANGES (original)
+++ trunk/fsvs/CHANGES 2008-04-03 22:14:34-0700
@@ -5,6 +5,7 @@
     reduce code size. Now it's possible to use "-oconf=..." on the command
     line, too.
     (But it's not possible to override the paths from the config file.)
+- Fixed EPIPE handling in many functions, most notably on "fsvs st" output.
 
 Changes since 1.1.13
 - New option for conflict handling; allows "stop" (historical default),

Modified: trunk/fsvs/src/cp_mv.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/cp_​mv.c?view=diff&r​ev=1586&p1=trunk​/fsvs/src/cp_mv.c​&p2=trunk/fsvs/src/​cp_mv.c&r1=1585​&r2=1586
====================​====================​====================​==================
--- trunk/fsvs/src/cp_mv.c (original)
+++ trunk/fsvs/src/cp_mv.c 2008-04-03 22:14:34-0700
@@ -688,7 +688,6 @@
     struct cm___candidate_t candidates[HASH__LIS​T_MAX*CM___MATCH_NUM​];
     struct cm___candidate_t *cur, *list;
     size_t candidate_count;
- int output_error;
     FILE *output=stdout;
 
 
@@ -700,7 +699,6 @@
 
     formatted=NULL;
     status=0;
- output_error=0;
     candidate_count=0;
     overflows=0;
     path=NULL;
@@ -765,7 +763,7 @@
         STOPIF( hlp__format_path(entry, path, &formatted), NULL);
 
         /* Print header line for this file. */
- output_error |= fprintf(output, "%s\n", formatted);
+ STOPIF_CODE_EPIPE( fprintf(output, "%s\n", formatted), NULL);
 
         /* Output list of matches */
         for(j=0; j<candidate_count; j++)
@@ -773,7 +771,7 @@
             sts=candidates[j].sts;
             have_match=0;
 
- output_error |= fputs(" ", output);
+ STOPIF_CODE_EPIPE( fputs(" ", output), NULL);
 
             for(i=0; i<CM___MATCH_NUM; i++)
             {
@@ -782,24 +780,25 @@
                     match=cm___match_array+i;
 
                     if (have_match)
- output_error |= fputs(",", output);
+ STOPIF_CODE_EPIPE( fputs(",", output), NULL);
                     have_match=1;
 
- output_error |= fputs(match->name, output);
+ STOPIF_CODE_EPIPE( fputs(match->name, output), NULL);
                     if (opt_verbose && match->format)
- output_error |=
- fputs( match->format(match, candidates+j), output);
+ STOPIF_CODE_EPIPE(
+ fputs( match->format(match, candidates+j), output),
+ NULL);
                 }
             }
 
             STOPIF( ops__build_path(&path, sts), NULL);
             STOPIF( hlp__format_path(sts, path, &formatted), NULL);
- output_error |= fprintf(output, ":%s\n", formatted);
+ STOPIF_CODE_EPIPE( fprintf(output, ":%s\n", formatted), NULL);
         }
 
 
         if (overflows)
- output_error |= fputs(" ...\n", output);
+ STOPIF_CODE_EPIPE( fputs(" ...\n", output), NULL);
     }
     else
     {
@@ -809,17 +808,15 @@
         if (opt_verbose>0)
         {
             STOPIF( hlp__format_path(entry, path, &formatted), NULL);
- output_error |= fprintf(output, "- No copyfrom relation found for %s\n", formatted);
+ STOPIF_CODE_EPIPE( fprintf(output,
+ "- No copyfrom relation found for %s\n",
+ formatted), NULL);
         }
         else
             DEBUGP("No sources found for %s", path);
     }
 
- output_error |= fflush(output);
-
- /* Could be something else ... but we can't write data, so we quit. */
- if (output_error<0)
- status=EPIPE;
+ STOPIF_CODE_EPIPE( fflush(output), NULL);
 
 ex:
     return status;
@@ -967,10 +964,10 @@
     STOPIF( cm__find_copied(root), NULL);
 
     if (!copydetect_count)
- printf("No copyfrom relations found.\n");
+ STOPIF_CODE_EPIPE( printf("No copyfrom relations found.\n"), NULL);
     else if (opt_verbose>0)
- printf("%d copyfrom relation%s found.\n",
- copydetect_count, copydetect_count == 1 ? "" : "s");
+ STOPIF_CODE_EPIPE( printf("%d copyfrom relation%s found.\n",
+ copydetect_count, copydetect_count == 1 ? "" : "s"), NULL);
 
 ex:
     for(i=0; i<CM___MATCH_NUM; i++)
@@ -1132,17 +1129,7 @@
         status |= fprintf(output, "%s\n%s\n", path, key.dptr);
         IF_FREE(value.dptr);
 
- if (status < 0)
- {
- status=errno;
- if (status == EPIPE)
- {
- status=0;
- break;
- }
-
- STOPIF(status, "output error");
- }
+ STOPIF_CODE_ERR( status < 0, -EPIPE, "output error");
 
         status=hsh__next(db, &key, &key);
         have++;

Modified: trunk/fsvs/src/diff.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/dif​f.c?view=diff&re​v=1586&p1=trunk/​fsvs/src/diff.c&​p2=trunk/fsvs/src/di​ff.c&r1=1585​&r2=1586
====================​====================​====================​==================
--- trunk/fsvs/src/diff.c (original)
+++ trunk/fsvs/src/diff.c 2008-04-03 22:14:34-0700
@@ -121,16 +121,12 @@
             l1>=META_DIFF_MAXLEN || l2>=META_DIFF_MAXLEN, EINVAL,
             "Printing meta-data strings format error");
 
- if (l1 != l2 || strcmp(buf_new, buf_old) !=0)
         /* Different */
- status=printf("-%s\n+%s\n", buf_old, buf_new);
- else
- status=printf(" %s\n", buf_old);
-
- STOPIF_CODE_ERR(status<0, errno,
- "Meta-data diff output error");
-
- status=0;
+ STOPIF_CODE_EPIPE(
+ printf(
+ (l1 != l2 || strcmp(buf_new, buf_old) !=0) ?
+ "-%s\n+%s\n" : " %s\n",
+ buf_old, buf_new), NULL);
 
 ex:
     return status;

Modified: trunk/fsvs/src/dox/dev.dox
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/dox​/dev.dox?view=diff​&rev=1586&p1=t​runk/fsvs/src/dox/de​v.dox&p2=trunk/f​svs/src/dox/dev.dox​&r1=1585&r2=1​586
====================​====================​====================​==================
--- trunk/fsvs/src/dox/dev.dox (original)
+++ trunk/fsvs/src/dox/dev.dox 2008-04-03 22:14:34-0700
@@ -179,7 +179,7 @@
 or it must be returned to the caller.
 Most of this is already defined in macros.
 
-Typical function layout is like this (taken from waa.c):
+Typical function layout is like this (taken from <tt>waa.c</tt>):
 \code
   int waa__make_info_link(char *directory, char *name, char *dest)
   {
@@ -237,6 +237,12 @@
 depending on the debug- and verbosity-flags given on the command line,
 a back trace too.
 
+Another special case is output to \c STDOUT; if we get an error \c EPIPE
+here, we pass it up to main() as \c -EPIPE (to avoid confusion with writing
+some other data), where it gets ignored. To avoid printing an error message
+this is hardcoded in the \c STOPIF() macros.
+
+
 Assertions should be checked by \c BUG_ON(condition, format_string, ...).
 This will cause a segmentation violation, which (for debug builds) will
 automatically attach a debugger (\c gdb, only if present on the system).

Modified: trunk/fsvs/src/fsvs.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/fsv​s.c?view=diff&re​v=1586&p1=trunk/​fsvs/src/fsvs.c&​p2=trunk/fsvs/src/fs​vs.c&r1=1585​&r2=1586
====================​====================​====================​==================
--- trunk/fsvs/src/fsvs.c (original)
+++ trunk/fsvs/src/fsvs.c 2008-04-03 22:14:34-0700
@@ -475,7 +475,10 @@
  *
  * In case the first character of the \a format is a <tt>"!"</tt>, it's a
  * user error - here we normally print only the message, without the error
- * code line. The full details are available via \c -d and \c -v. */
+ * code line. The full details are available via \c -d and \c -v.
+ *
+ * \c -EPIPE is handled specially, in that it is passed up, but no message
+ * is printed. */
 int _STOP(const char *file, int line, const char *function,
         int errl, const char *format, ...)
 {
@@ -491,6 +494,7 @@
 
 
     if (make_STOP_silent) return errl;
+ if (errl==-EPIPE) return errl;
 
     is_usererror= format && *format == '!';
     if (is_usererror) format++;
@@ -1247,7 +1251,9 @@
     mem_end=sbrk(0);
     DEBUGP("memory stats: %p to %p, %llu KB",
             mem_start, mem_end, (t_ull)(mem_end-mem_​start)/1024);
- if (status)
+ if (status == -EPIPE)
+ DEBUGP("got EPIPE, ignoring.");
+ else if (status)
         return 1;
 
     _DEBUGP(NULL, 0, NULL, NULL);

Modified: trunk/fsvs/src/global.h
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/glo​bal.h?view=diff&​rev=1586&p1=trun​k/fsvs/src/global.h​&p2=trunk/fsvs/sr​c/global.h&r1=15​85&r2=1586
====================​====================​====================​==================
--- trunk/fsvs/src/global.h (original)
+++ trunk/fsvs/src/global.h 2008-04-03 22:14:34-0700
@@ -614,7 +614,7 @@
     if (cond) \
     { \
         status=code; \
- _STOP(__FILE__, __LINE__, __PRETTY_FUNCTION__, code, __VA_ARGS__); \
+ _STOP(__FILE__, __LINE__, __PRETTY_FUNCTION__, code, __VA_ARGS__); \
         goto go; \
     } \
 } while (0)
@@ -637,14 +637,14 @@
  * \param code The status code to check.
  * All other things are hardcoded. */
 #define STOPIF(code, ... ) \
- do \
+ do \
 { \
- status=code; \
- if (status) \
- { \
+ status=(code); \
+ if (status) \
+ { \
         _STOP(__FILE__, __LINE__, __PRETTY_FUNCTION__, status, __VA_ARGS__); \
         goto ex; \
- } \
+ } \
 } while (0)
 /** A simplified error call macro for returning ENOMEM.
  * \code
@@ -655,6 +655,21 @@
  * \endcode
  * */
 #define STOPIF_ENOMEM(cond) STOPIF_CODE_ERR(cond, ENOMEM, NULL)
+/** An error return macro that is used for user output - special handling
+ * \c EPIPE to get a silent return.
+ * If \c code returns something negative (like printf, puts, putc ... do;
+ * \c EOF is defined as \c -1), and \a error is \c EPIPE, go on with \c
+ * -EPIPE. */
+#define STOPIF_CODE_EPIPE(code, ...) \
+ do \
+{ \
+ if ((code) < 0) \
+ { \
+ status=errno; \
+ if (status == EPIPE) status= -EPIPE; \
+ STOPIF(status, "Error writing output"); \
+ } \
+} while (0)
 
 /** \page svnlibwrap Subversion library calls wrapper.
  * If this is used in some function, an additional variable is needed:
@@ -676,18 +691,12 @@
  * \endcode
  */
 /** The master error macro for calling subversion functions. */
-#define STOPIF_SVNERR_EXTRA(func, parm, fmt, ...)\
- do \
-{ \
- status_svn=func parm; \
- if (status_svn) \
- { \
- status=status_svn->apr_err; \
- _STOP(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
- status_svn->apr_err, \
- fmt ": %s", ## __VA_ARGS__, status_svn->message);\
- goto ex; \
- } \
+#define STOPIF_SVNERR_EXTRA(func, parm, fmt, ...) \
+ do \
+{ \
+ status_svn=func parm; \
+ STOPIF_CODE_ERR( status_svn, status_svn->apr_err, \
+ fmt ": %s", ## __VA_ARGS__, status_svn->message); \
 } while (0)
 /* The mainly used function wrapper.
  * \param func Name of the subversion function
@@ -696,7 +705,7 @@
  * STOPIF_SVNERR( svn_ra_initialize, (global_pool));
  * \endcode
  */
-#define STOPIF_SVNERR(func, parm) STOPIF_SVNERR_TEXT(func, #func, parm)
+#define STOPIF_SVNERR(func, parm) STOPIF_SVNERR_EXTRA(func, parm, #func)
 /** The same as STOPIF_SVNERR(), but with a variable printed function name.
  * Used in case the function is called indirectly; see STOPIF_SVNERR_INDIR. */
 #define STOPIF_SVNERR_TEXT(func, text, parm) STOPIF_SVNERR_EXTRA(func, parm, text)

Modified: trunk/fsvs/src/helper.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/hel​per.c?view=diff&​rev=1586&p1=trun​k/fsvs/src/helper.c​&p2=trunk/fsvs/sr​c/helper.c&r1=15​85&r2=1586
====================​====================​====================​==================
--- trunk/fsvs/src/helper.c (original)
+++ trunk/fsvs/src/helper.c 2008-04-03 22:14:34-0700
@@ -815,7 +815,7 @@
 
         if (cur == 0x7f)
         {
- status=fputs("\\x7f", output);
+ STOPIF_CODE_EPIPE( fputs("\\x7f", output), NULL);
             continue;
         }
 
@@ -823,22 +823,15 @@
          * The things above 0x80 are needed. */
         if (cur<sizeof(to_encode) || !isprint(cur))
         {
- status=
- to_encode[cur] ? fprintf(output, "\\%c", to_encode[cur]) :
- fprintf(output, "\\x%02x", cur);
+ STOPIF_CODE_EPIPE(
+ to_encode[cur] ?
+ fprintf(output, "\\%c", to_encode[cur]) :
+ fprintf(output, "\\x%02x", cur), NULL);
             continue;
         }
 
         /* Normal (or at least unfiltered) character. */
- status=fputc(cur, output);
- }
-
- if (status<0)
- {
- status=errno;
- if (status != EPIPE)
- STOPIF(status, "Cannot write data");
- goto ex;
+ STOPIF_CODE_EPIPE( fputc(cur, output), NULL);
     }
 
     status=0;

Modified: trunk/fsvs/src/log.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/log​.c?view=diff&rev​=1586&p1=trunk/f​svs/src/log.c&p2​=trunk/fsvs/src/log.​c&r1=1585&r2​=1586
====================​====================​====================​==================
--- trunk/fsvs/src/log.c (original)
+++ trunk/fsvs/src/log.c 2008-04-03 22:14:34-0700
@@ -131,19 +131,18 @@
     STOPIF( log___divider(output, ANSI__GREEN), NULL);
 
     /* Taken from a svn commit message. */
- STOPIF_CODE_ERR( -1 == fprintf(output,
- "r%llu | %s | %s | %d line%s\n"
- "%s",
- (t_ull)revision, auth, dat, lines,
- lines == 1 ? "" : "s",
- (opt__get_int(OPT__LOG_OUTPUT) & LOG__OPT_COLOR) ? ANSI__NORMAL : ""),
- errno, NULL);
+ STOPIF_CODE_EPIPE( fprintf(output,
+ "r%llu | %s | %s | %d line%s\n"
+ "%s",
+ (t_ull)revision, auth, dat, lines,
+ lines == 1 ? "" : "s",
+ (opt__get_int(OPT__LOG_OUTPUT) & LOG__OPT_COLOR) ? ANSI__NORMAL : ""),
+ NULL);
 
     /* Print optionally the filenames */
     if (changed_paths)
     {
- STOPIF_CODE_ERR( -1 == fputs("Changed paths:\n", output),
- errno, NULL);
+ STOPIF_CODE_EPIPE( fputs("Changed paths:\n", output), NULL);
         hi=apr_hash_first(pool, changed_paths);
         while (hi)
         {
@@ -151,13 +150,12 @@
 
             STOPIF( hlp__utf82local( name, &local_name, namelen), NULL);
 
- STOPIF_CODE_ERR( -1 == fprintf(output, " %s\n", local_name),
- errno, NULL);
+ STOPIF_CODE_EPIPE( fprintf(output, " %s\n", local_name), NULL);
             hi = apr_hash_next(hi);
         }
     }
 
- STOPIF_CODE_ERR( -1 == fputs("\n", output), errno, NULL);
+ STOPIF_CODE_EPIPE( fputs("\n", output), NULL);
 
     /* Convert the message in parts;
      * - so that not too big buffers are processed at once, and
@@ -201,7 +199,7 @@
         DEBUGP("log output: %d bytes", cur);
 
         STOPIF( hlp__utf82local(message, &mess, cur), NULL);
- STOPIF_CODE_ERR( fputs(mess, output) == EOF, errno, NULL);
+ STOPIF_CODE_EPIPE( fputs(mess, output), NULL);
 
         message+=cur;
         len-=cur;
@@ -211,7 +209,7 @@
         sol= ccp!=NULL;
     }
 
- STOPIF_CODE_ERR( putc('\n', output) == EOF, EPIPE, NULL);
+ STOPIF_CODE_EPIPE( putc('\n', output), NULL);
 
 ex:
     RETURN_SVNERR(status);
@@ -318,7 +316,8 @@
         opt_target_revision2=head;
 
 
- status_svn=svn_ra_ge​t_log(session,
+ STOPIF_SVNERR( svn_ra_get_log,
+ (session,
              paths,
              opt_target_revision,
              opt_target_revision2,
@@ -327,20 +326,7 @@
              0, // TODO: stop-on-copy,
              log__receiver,
              output,
- global_pool);
-
- /* Quit silently on EPIPE. */
- if (status_svn &&
- status_svn->apr_err == EPIPE)
- {
- status=0;
- status_svn=NULL;
- goto ex;
- }
-
- /* A bit of a hack. */
- STOPIF_SVNERR(status_svn, +0);
-
+ global_pool) );
 
     STOPIF( log___divider(output, ANSI__NORMAL), NULL);
 

Modified: trunk/fsvs/src/status.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/sta​tus.c?view=diff&​rev=1586&p1=trun​k/fsvs/src/status.c​&p2=trunk/fsvs/sr​c/status.c&r1=15​85&r2=1586
====================​====================​====================​==================
--- trunk/fsvs/src/status.c (original)
+++ trunk/fsvs/src/status.c 2008-04-03 22:14:34-0700
@@ -216,17 +216,17 @@
     STOPIF( hlp__format_path(sts, path, &path), NULL);
 
 
- status= 0>
- printf("%s%c%s%c%c %8s %s%s%s%s%s\n",
- opt__get_int(OPT__STATUS_COLOR) ? st___color(status_bits) : "",
-
- flags & RF_ADD ? 'n' :
- flags & RF_UNVERSION ? 'd' :
- (status_bits & FS_REPLACED) == FS_REPLACED ? 'R' :
- status_bits & FS_NEW ? 'N' :
- status_bits & FS_REMOVED ? 'D' : '.',
+ STOPIF_CODE_ERR(
+ printf("%s%c%s%c%c %8s %s%s%s%s%s\n",
+ opt__get_int(OPT__STATUS_COLOR) ? st___color(status_bits) : "",
+
+ flags & RF_ADD ? 'n' :
+ flags & RF_UNVERSION ? 'd' :
+ (status_bits & FS_REPLACED) == FS_REPLACED ? 'R' :
+ status_bits & FS_NEW ? 'N' :
+ status_bits & FS_REMOVED ? 'D' : '.',
 
- st___meta_string(status_bits, flags),
+ st___meta_string(status_bits, flags),
 
                     flags & RF_CONFLICT ? 'x' :
                     status_bits & FS_CHANGED ? 'C' : '.',
@@ -238,17 +238,16 @@
                     ( ( status_bits & FS_REMOVED ) &&
                         ( flags & (RF_UNVERSION | RF_ADD) ) ) ? '!' : '.',
 
- size, path,
- opt__get_int(OPT__STATUS_COLOR) ? ANSI__NORMAL : "",
-
+ size, path,
+ opt__get_int(OPT__STATUS_COLOR) ? ANSI__NORMAL : "",
+
                     /* Here the comparison of opt_verbose is already included in the
                      * check on copyfrom above. */
                     copyfrom ? " (copied from " : "",
                     copyfrom ? copyfrom :
                         copy_inherited ? " (inherited)" : "",
- copyfrom ? ")" : "");
- /* possibly a EPIPE */
- STOPIF_CODE_ERR(status, errno, "Broken Pipe");
+ copyfrom ? ")" : "") == -1,
+ errno, "Error printing output");
   }
 
 
@@ -644,72 +643,73 @@
     }
 
     if (with_type)
- status=printf("\tTy​pe:\t\t%s\n",
- st___string_from_bit​s(sts->entry_type​, types, "invalid") );
+ STOPIF_CODE_EPIPE( printf("\tType:\t\t%s\n",
+ st___string_from_bit​s(sts->entry_type​, types, "invalid") ), NULL);
     if (sts->entry_type == FT_DIR)
- status |= printf("\tChildCount:\t%u\n", sts->entry_count);
- status |= printf("\tURL:\t\t%s\n", url);
- status |= printf("\tStatus:\t\t0x%X (%s)\n", sts->entry_status,
- st__status_string(sts));
- status |= printf("\tFlags:\t\t0x%X (%s)\n",
- sts->flags & ~RF_PRINT,
- st__flags_string_fro​mint(sts->flags))​;
+ STOPIF_CODE_EPIPE( printf( "\tChildCount:\t%u\n",
+ sts->entry_count), NULL);
+ STOPIF_CODE_EPIPE( printf("\tURL:\t\t%s\n", url), NULL);
+ STOPIF_CODE_EPIPE( printf("\tStatus:\t\t0x%X (%s)\n",
+ sts->entry_status, st__status_string(sts)), NULL);
+ STOPIF_CODE_EPIPE( printf("\tFlags:\t\t0x%X (%s)\n",
+ sts->flags & ~RF_PRINT,
+ st__flags_string_fro​mint(sts->flags))​, NULL);
 
     if (opt_verbose && copyfrom)
     {
- status |= printf("\tCopyfrom:\trev. %llu of %s\n",
- (t_ull)copy_rev, copyfrom);
+ STOPIF_CODE_EPIPE( printf("\tCopyfrom:\trev. %llu of %s\n",
+ (t_ull)copy_rev, copyfrom), NULL);
     }
 
- status |= printf("\tDev:\t\t%llu\n", (t_ull)sts->st.dev);
- status |= printf("\tInode:\t\t%llu\n", (t_ull)sts->st.ino);
- status |= printf("\tMode:\t\t0%4o\n", sts->st.mode);
- status |= printf("\tUID/GID:\t%u (%s)/%u (%s)\n",
- sts->st.uid, hlp__get_uname(sts->st.uid, "undefined"),
- sts->st.gid, hlp__get_grname(sts->st.gid, "undefined") );
+ STOPIF_CODE_EPIPE( printf("\tDev:\t\t%llu\n",
+ (t_ull)sts->st.dev), NULL);
+ STOPIF_CODE_EPIPE( printf("\tInode:\t\t%llu\n",
+ (t_ull)sts->st.ino), NULL);
+ STOPIF_CODE_EPIPE( printf("\tMode:\t\t0%4o\n",
+ sts->st.mode), NULL);
+ STOPIF_CODE_EPIPE( printf("\tUID/GID:\t%u (%s)/%u (%s)\n",
+ sts->st.uid, hlp__get_uname(sts->st.uid, "undefined"),
+ sts->st.gid, hlp__get_grname(sts->st.gid, "undefined") ), NULL);
     /* Remove the \n at the end */
- status |= printf("\tMTime:\t\t%.24s\n", ctime( &(sts->st.mtim.tv_sec) ));
- status |= printf("\tCTime:\t\t%.24s\n", ctime( &(sts->st.ctim.tv_sec) ));
+ STOPIF_CODE_EPIPE( printf("\tMTime:\t\t%.24s\n",
+ ctime( &(sts->st.mtim.tv_sec) )), NULL);
+ STOPIF_CODE_EPIPE( printf("\tCTime:\t\t%.24s\n",
+ ctime( &(sts->st.ctim.tv_sec) )), NULL);
 
     STOPIF( waa__get_waa_directory(path, &waa_path, NULL, NULL,
                 GWD_WAA), NULL);
- status |= printf("\tWAA-Path:\t%s\n", waa_path);
+ STOPIF_CODE_EPIPE( printf("\tWAA-Path:\t%s\n",
+ waa_path), NULL);
 
     if (!sts->parent)
     {
         STOPIF( waa__get_waa_directory(path, &waa_path, NULL, NULL,
                     GWD_CONF), NULL);
- status |= printf("\tConf-Path:\t%s\n", waa_path);
+ STOPIF_CODE_EPIPE( printf("\tConf-Path:\t%s\n",
+ waa_path), NULL);
     }
 
- status |= printf("\tRevision:\t%li\n", sts->repos_rev);
+ STOPIF_CODE_EPIPE( printf("\tRevision:\t%li\n",
+ sts->repos_rev), NULL);
 
     if (sts->entry_type==FT_FILE)
- status |= printf("\tRepos-MD5:\t%s\n",
- cs__md52hex(sts->md5));
+ STOPIF_CODE_EPIPE( printf("\tRepos-MD5:\t%s\n",
+ cs__md52hex(sts->md5)), NULL);
 
     if (sts->entry_type==FT_BDEV || sts->entry_type==FT_CDEV)
 #ifdef DEVICE_NODES_DISABLED
         DEVICE_NODES_DISABLED();
 #else
- status |= printf("\tDevice number:\t%llu:%llu\n",
+ STOPIF_CODE_EPIPE( printf("\tDevice number:\t%llu:%llu\n",
                 (t_ull)MAJOR(sts->st.rdev),
- (t_ull)MINOR(sts->st.rdev));
+ (t_ull)MINOR(sts->st.rdev)), NULL);
 #endif
     else
- status |= printf("\tSize:\t\t%llu\n", (t_ull)sts->st.size);
+ STOPIF_CODE_EPIPE( printf("\tSize:\t\t%llu\n",
+ (t_ull)sts->st.size), NULL);
 
     /* Any last words? */
- status |= printf("\n");
-
- DEBUGP("status at end of info is 0x%X", status);
-
- /* Had a printf a negative return value? */
- if (status < 0)
- STOPIF_CODE_ERR( 1, errno ? errno : ENOSPC,
- "Output error on printing entry info");
- else
- status=0;
+ STOPIF_CODE_EPIPE( printf("\n"), NULL);
 
 ex:
     return status;

Modified: trunk/fsvs/src/url.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/url​.c?view=diff&rev​=1586&p1=trunk/f​svs/src/url.c&p2​=trunk/fsvs/src/url.​c&r1=1585&r2​=1586
====================​====================​====================​==================
--- trunk/fsvs/src/url.c (original)
+++ trunk/fsvs/src/url.c 2008-04-03 22:14:34-0700
@@ -960,25 +960,25 @@
                     switch (cp[1])
                     {
                         case '\\':
- status= EOF == fputc('\\', output);
+ STOPIF_CODE_EPIPE( fputc('\\', output), NULL);
                             break;
                         case 'n':
- status= EOF == fputc('\n', output);
+ STOPIF_CODE_EPIPE( fputc('\n', output), NULL);
                             break;
                         case 'r':
- status= EOF == fputc('\r', output);
+ STOPIF_CODE_EPIPE( fputc('\r', output), NULL);
                             break;
                         case 't':
- status= EOF == fputc('\t', output);
+ STOPIF_CODE_EPIPE( fputc('\t', output), NULL);
                             break;
                         case 'f':
- status= EOF == fputc('\f', output);
+ STOPIF_CODE_EPIPE( fputc('\f', output), NULL);
                             break;
                         case 'x':
                             status= cp[2] && cp[3] ? cs__two_ch2bin(cp+2) : -1;
                             STOPIF_CODE_ERR(status <0, EINVAL,
                                     "A \"\\x\" sequence must have 2 hex digits.");
- status= EOF == fputc(status, output);
+ STOPIF_CODE_EPIPE( fputc(status, output), NULL);
                             /* There's a +2 below. */
                             cp+=2;
                             break;
@@ -996,24 +996,27 @@
                     {
                         /* Allow internal number, too? */
                         case 'n':
- status= EOF == fputs(url->name ?: "", output);
+ STOPIF_CODE_EPIPE( fputs(url->name ?: "", output), NULL);
                             break;
                         case 't':
- status= EOF == fputs(hlp__rev_to_st​ring(url->target_​rev),
- output);
+ STOPIF_CODE_EPIPE( fputs(
+ hlp__rev_to_string(u​rl->target_rev),
+ output), NULL);
                             break;
                         case 'r':
- status= EOF == fputs( hlp__rev_to_string(u​rl->current_rev),​
- output);
+ STOPIF_CODE_EPIPE( fputs(
+ hlp__rev_to_string(u​rl->current_rev),​
+ output), NULL);
                             break;
                         case 'p':
- status= 0 > fprintf(output, "%u", url->priority);
+ STOPIF_CODE_EPIPE( fprintf(output, "%u",
+ url->priority), NULL);
                             break;
                         case 'u':
- status= EOF == fputs(url->url, output);
+ STOPIF_CODE_EPIPE( fputs(url->url, output), NULL);
                             break;
                         case '%':
- status= EOF == fputc('%', output);
+ STOPIF_CODE_EPIPE( fputc('%', output), NULL);
                             break;
                         default:
                             STOPIF_CODE_ERR(1, EINVAL,
@@ -1025,26 +1028,15 @@
                     break;
 
                 default:
- status= EOF == fputc(*cp, output);
+ STOPIF_CODE_EPIPE( fputc(*cp, output), NULL);
                     cp++;
             }
-
- if (status)
- {
- status=errno;
-
- /* Quit silently. */
- if (status == EPIPE)
- status=0;
-
- goto ex;
-
- }
         }
     }
 
-ex:
+ status=0;
 
+ex:
     return status;
 }
 

Modified: trunk/fsvs/src/warnings.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/war​nings.c?view=diff​&rev=1586&p1=tr​unk/fsvs/src/warning​s.c&p2=trunk/fsv​s/src/warnings.c​&r1=1585&r2=1586​
====================​====================​====================​==================
--- trunk/fsvs/src/warnings.c (original)
+++ trunk/fsvs/src/warnings.c 2008-04-03 22:14:34-0700
@@ -226,8 +226,7 @@
     status=0;
     /* Flush all streams, so that this warnings occur *after*
      * every other status output. */
- STOPIF_CODE_ERR( fflush(NULL) == EOF, errno,
- "Could not flush output streams");
+ STOPIF_CODE_EPIPE( fflush(NULL), NULL);
 
     flag=0;
     for(i=0; i<_WRN__LAST_INDEX; i++)

Modified: trunk/fsvs/tests/018_various
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/tests/0​18_various?view=diff​&rev=1586&p1​=trunk/fsvs/tests/01​8_various&p2=tru​nk/fsvs/tests/018_va​rious&r1=1585​&r2=1586
====================​====================​====================​==================
--- trunk/fsvs/tests/018_various (original)
+++ trunk/fsvs/tests/018_various 2008-04-03 22:14:34-0700
@@ -94,25 +94,30 @@
 
 
 # Test EPIPE handling.
-# I could reproduce it with "strace -o /dev/null $BINdflt log | head -1",
-# but only in 1 of 10 cases without the strace.
-# Any error code $BINdflt would give is overwritten by "head"; so we use a
-# perl loop here.
+# I could reproduce it with "strace -o /dev/null $BINdflt log | true", (or
+# "| head -1"), but only in 1 of 10 cases without the strace.
 strace_bin=`which strace || true`
 strace_cmd=${strace​_bin:+$strace_bin -o /dev/null}
-cmd="$strace_cmd $BINdflt log"
-if perl -e '$cmd=shift(); for(1 .. 10) { open(F, $cmd . " |") || die $!; close(F) || die $!; }' "$cmd" > $logfile 2>&1
-then
- # No errors on STDOUT allowed.
- if [[ `wc -l < $logfile` -eq 0 ]]
+for command in log st
+do
+ ret=$(
+ set -o pipefail
+ $strace_cmd $BINdflt $command 2>$logfile | true
+ echo $?
+ set +o pipefail )
+ if [[ $ret -eq 0 ]]
     then
- $SUCCESS "EPIPE handled correctly"
+ # No errors on STDOUT allowed.
+ if [[ `wc -l < $logfile` -eq 0 ]]
+ then
+ $SUCCESS "EPIPE on $command handled correctly"
+ else
+ $ERROR "wrong number of output lines on EPIPE $command test"
+ fi
     else
- $ERROR "wrong number of output lines on EPIPE test"
+ $ERROR "Error code on EPIPE $command"
     fi
-else
- $ERROR "Error code on EPIPE"
-fi
+done
 
 
 # Test whether / at the end of an URL are removed

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r1586 - trunk: . fsvs fsvs/src fsvs/src/dox fsvs/tests pmarek P.Marek 2008-04-03 22:14:35 PDT
Messages per page: