Changeset 9b20126 in mainline for uspace/lib/pcut/src/assert.c
- Timestamp:
- 2014-09-19T08:23:01Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c85a57f
- Parents:
- 15d0046
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/src/assert.c
r15d0046 r9b20126 35 35 */ 36 36 37 /** We need _BSD_SOURCE because of vsnprintf() when compiling under C89. */ 38 #define _BSD_SOURCE 39 37 40 #include "internal.h" 38 41 #include <setjmp.h> … … 52 55 static int message_buffer_index = 0; 53 56 54 /** Announce that assertion failed. 55 * 56 * @warning This function may not return. 57 * 58 * @param fmt printf-style formatting string. 59 * 60 */ 61 void pcut_failed_assertion_fmt(const char *fmt, ...) { 57 void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...) { 58 va_list args; 62 59 char *current_buffer = message_buffer[message_buffer_index]; 60 size_t offset = 0; 63 61 message_buffer_index = (message_buffer_index + 1) % MESSAGE_BUFFER_COUNT; 64 62 65 va_list args; 66 va_start(args, fmt); 67 vsnprintf(current_buffer, MAX_MESSAGE_LENGTH, fmt, args); 68 va_end(args); 63 snprintf(current_buffer, MAX_MESSAGE_LENGTH, "%s:%d: ", filename, line); 64 offset = pcut_str_size(current_buffer); 65 66 if (offset + 1 < MAX_MESSAGE_LENGTH) { 67 va_start(args, fmt); 68 vsnprintf(current_buffer + offset, MAX_MESSAGE_LENGTH - offset, fmt, args); 69 va_end(args); 70 } 69 71 70 72 pcut_failed_assertion(current_buffer);
Note:
See TracChangeset
for help on using the changeset viewer.