Coverage Report

Created: 2026-01-07 06:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/util-linux/libblkid/src/version.c
Line
Count
Source
1
/*
2
 * version.c --- Return the version of the blkid library
3
 *
4
 * Copyright (C) 2004 Theodore Ts'o.
5
 *
6
 * %Begin-Header%
7
 * This file may be redistributed under the terms of the GNU Lesser General
8
 * Public License.
9
 * %End-Header%
10
 */
11
12
#ifdef HAVE_UNISTD_H
13
#include <unistd.h>
14
#endif
15
#include <string.h>
16
#include <stdio.h>
17
#include <ctype.h>
18
19
#include "blkid.h"
20
21
/* LIBBLKID_* defined in the global config.h */
22
static const char *lib_version = LIBBLKID_VERSION;  /* release version */
23
static const char *lib_date = LIBBLKID_DATE;
24
25
/**
26
 * blkid_parse_version_string:
27
 * @ver_string:  version string (e.g. "2.16.0")
28
 *
29
 * Returns: release version code.
30
 */
31
int blkid_parse_version_string(const char *ver_string)
32
0
{
33
0
  const char *cp;
34
0
  int version = 0;
35
36
0
  for (cp = ver_string; *cp; cp++) {
37
0
    if (*cp == '.')
38
0
      continue;
39
0
    if (!isdigit(*cp))
40
0
      break;
41
0
    version = (version * 10) + (*cp - '0');
42
0
  }
43
0
  return version;
44
0
}
45
46
/**
47
 * blkid_get_library_version:
48
 * @ver_string: returns release version (!= SONAME version)
49
 * @date_string: returns date
50
 *
51
 * Returns: release version code.
52
 */
53
int blkid_get_library_version(const char **ver_string,
54
             const char **date_string)
55
0
{
56
0
  if (ver_string)
57
0
    *ver_string = lib_version;
58
0
  if (date_string)
59
0
    *date_string = lib_date;
60
61
0
  return blkid_parse_version_string(lib_version);
62
0
}