afs assert should use afs abort
[openafs.git] / src / util / assert.c
index 757d976..49834cc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 
-RCSID
-    ("$Header$");
 
 #include <stdio.h>
 #include "afsutil.h"
@@ -36,21 +28,20 @@ afs_NTAbort(void)
 }
 #endif
 
+#define TIMESTAMP_BUFFER_SIZE 26  /* including the null */
+#define TIMESTAMP_NEWLINE_POS 24  /* offset to the newline placed by ctime */
 
 void
 AssertionFailed(char *file, int line)
 {
-    char tdate[26];
+    char tdate[TIMESTAMP_BUFFER_SIZE];
     time_t when;
 
     time(&when);
-    afs_ctime(&when, tdate, 25);
-    fprintf(stderr, "%s: Assertion failed! file %s, line %d.\n", tdate, file,
+    (void)afs_ctime(&when, tdate, sizeof(tdate));
+    tdate[TIMESTAMP_NEWLINE_POS] = ' ';
+    fprintf(stderr, "%sAssertion failed! file %s, line %d.\n", tdate, file,
            line);
     fflush(stderr);
-#ifdef AFS_NT40_ENV
-    afs_NTAbort();
-#else
-    abort();
-#endif
+    afs_abort();
 }