Changeset e06e2716 in mainline for uspace/lib/c/generic/assert.c


Ignore:
Timestamp:
2011-05-22T19:17:56Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9ea8fdb4
Parents:
13f2461
Message:

Passing stringified LINE does not conserve space very well,
pass it as integer again.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/assert.c

    r13f2461 re06e2716  
    3737#include <atomic.h>
    3838#include <stacktrace.h>
     39#include <stdint.h>
    3940
    4041#define MSG_START       "Assertion failed ("
     
    4546static atomic_t failed_asserts;
    4647
    47 void assert_abort(const char *cond, const char *file, const char *line)
     48void assert_abort(const char *cond, const char *file, unsigned int line)
    4849{
     50        char lstr[11];
     51        char *pd = &lstr[10];
     52        uint32_t ln = (uint32_t) line;
     53
     54        /*
     55         * Convert ln to a zero-terminated string.
     56         */
     57        *pd-- = 0;
     58        for (; ln; ln /= 10)
     59                *pd-- = '0' + ln % 10;
     60        pd++;
     61
    4962        /*
    5063         * Send the message safely to klog. Nested asserts should not occur.
     
    5568        klog_write(file, str_size(file));
    5669        klog_write(MSG_LINE, str_size(MSG_LINE));
    57         klog_write(line, str_size(line));
     70        klog_write(pd, str_size(pd));
    5871        klog_write(MSG_END, str_size(MSG_END));
    5972
     
    6982         * assertions.
    7083         */
    71         printf(MSG_START "%s" MSG_FILE "%s" MSG_LINE "%s" MSG_END,
     84        printf(MSG_START "%s" MSG_FILE "%s" MSG_LINE "%" PRIu32 MSG_END,
    7285            cond, file, line);
    7386        stacktrace_print();
Note: See TracChangeset for help on using the changeset viewer.