Changeset 46577995 in mainline for uspace/lib/fmtutil


Ignore:
Timestamp:
2018-01-04T20:50:52Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
e211ea04
Parents:
facacc71
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:47:53)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:50:52)
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

After this commit, HelenOS is free of code that mixes error codes with non-error
values on the assumption that error codes are negative.

Location:
uspace/lib/fmtutil
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/fmtutil/fmtutil.c

    rfacacc71 r46577995  
    3838} printmode_t;
    3939
    40 int print_wrapped_console(const char *str, align_mode_t alignment)
     40errno_t print_wrapped_console(const char *str, align_mode_t alignment)
    4141{
    4242        console_ctrl_t *console = console_init(stdin, stdout);
     
    4646        }
    4747        sysarg_t con_rows, con_cols, con_col, con_row;
    48         int rc = console_get_size(console, &con_cols, &con_rows);
     48        errno_t rc = console_get_size(console, &con_cols, &con_rows);
    4949        if (rc != EOK) {
    5050                return rc;
     
    6363 *
    6464 **/
    65 static int print_line(wchar_t *wstr, size_t chars, bool last, void *data)
     65static errno_t print_line(wchar_t *wstr, size_t chars, bool last, void *data)
    6666{
    6767        printmode_t *pm = (printmode_t *) data;
    6868        wchar_t old_char = wstr[chars];
    6969        wstr[chars] = 0;
    70         int rc = print_aligned_w(wstr, pm->width, last, pm->alignment);
     70        errno_t rc = print_aligned_w(wstr, pm->width, last, pm->alignment);
    7171        wstr[chars] = old_char;
    7272        return rc;
    7373}
    7474
    75 int print_wrapped(const char *str, size_t width, align_mode_t mode)
     75errno_t print_wrapped(const char *str, size_t width, align_mode_t mode)
    7676{
    7777        printmode_t pm;
     
    8383                return ENOMEM;
    8484        }
    85         int rc = wrap(wstr, width, print_line, &pm);
     85        errno_t rc = wrap(wstr, width, print_line, &pm);
    8686        free(wstr);
    8787        return rc;
    8888}
    8989
    90 int print_aligned_w(const wchar_t *wstr, size_t width, bool last,
     90errno_t print_aligned_w(const wchar_t *wstr, size_t width, bool last,
    9191    align_mode_t mode)
    9292{
     
    169169        return EOK;
    170170}
    171 int print_aligned(const char *str, size_t width, bool last, align_mode_t mode)
     171errno_t print_aligned(const char *str, size_t width, bool last, align_mode_t mode)
    172172{
    173173        wchar_t *wstr = str_to_awstr(str);
     
    175175                return ENOMEM;
    176176        }
    177         int rc = print_aligned_w(wstr, width, last, mode);
     177        errno_t rc = print_aligned_w(wstr, width, last, mode);
    178178        free(wstr);
    179179        return rc;
    180180}
    181181
    182 int wrap(wchar_t *wstr, size_t width, line_consumer_fn consumer, void *data)
     182errno_t wrap(wchar_t *wstr, size_t width, line_consumer_fn consumer, void *data)
    183183{
    184184        size_t word_start = 0;
  • uspace/lib/fmtutil/fmtutil.h

    rfacacc71 r46577995  
    4444 * @returns EOK on success or an error code on failure
    4545 */
    46 typedef int (*line_consumer_fn)(wchar_t *, size_t, bool, void *);
     46typedef errno_t (*line_consumer_fn)(wchar_t *, size_t, bool, void *);
    4747
    48 extern int print_aligned_w(const wchar_t *, size_t, bool, align_mode_t);
    49 extern int print_aligned(const char *, size_t, bool, align_mode_t);
    50 extern int print_wrapped(const char *, size_t, align_mode_t);
    51 extern int print_wrapped_console(const char *, align_mode_t);
     48extern errno_t print_aligned_w(const wchar_t *, size_t, bool, align_mode_t);
     49extern errno_t print_aligned(const char *, size_t, bool, align_mode_t);
     50extern errno_t print_wrapped(const char *, size_t, align_mode_t);
     51extern errno_t print_wrapped_console(const char *, align_mode_t);
    5252
    5353/** Wrap characters in a wide string to the given length.
     
    5858 * @param data user data to pass to the consumer function
    5959 */
    60 extern int wrap(wchar_t *, size_t, line_consumer_fn, void *);
     60extern errno_t wrap(wchar_t *, size_t, line_consumer_fn, void *);
Note: See TracChangeset for help on using the changeset viewer.