Coverage Report

Created: 2023-06-07 06:35

/src/e2fsprogs/lib/et/et_name.c
Line
Count
Source
1
/*
2
 * Copyright 1987 by MIT Student Information Processing Board
3
 *
4
 * Permission to use, copy, modify, and distribute this software and
5
 * its documentation for any purpose is hereby granted, provided that
6
 * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
7
 * advertising or publicity pertaining to distribution of the software
8
 * without specific, written prior permission.  M.I.T. and the
9
 * M.I.T. S.I.P.B. make no representations about the suitability of
10
 * this software for any purpose.  It is provided "as is" without
11
 * express or implied warranty.
12
 */
13
14
#include "config.h"
15
#include "com_err.h"
16
#include "error_table.h"
17
#include "internal.h"
18
19
static const char char_set[] =
20
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
21
22
static char buf[6];
23
24
const char * error_table_name(errcode_t num)
25
229k
{
26
229k
    int ch;
27
229k
    int i;
28
229k
    char *p;
29
30
    /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
31
229k
    p = buf;
32
229k
    num >>= ERRCODE_RANGE;
33
    /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
34
229k
    num &= 077777777L;
35
    /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
36
1.37M
    for (i = 4; i >= 0; i--) {
37
1.14M
  ch = (int)((num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1));
38
1.14M
  if (ch != 0)
39
916k
      *p++ = char_set[ch-1];
40
1.14M
    }
41
229k
    *p = '\0';
42
229k
    return(buf);
43
229k
}