OpenCoverage

hostid.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/hostid.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* print the hexadecimal identifier for the current host-
2-
3 Copyright (C) 1997-2018 Free Software Foundation, Inc.-
4-
5 This program is free software: you can redistribute it and/or modify-
6 it under the terms of the GNU General Public License as published by-
7 the Free Software Foundation, either version 3 of the License, or-
8 (at your option) any later version.-
9-
10 This program is distributed in the hope that it will be useful,-
11 but WITHOUT ANY WARRANTY; without even the implied warranty of-
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
13 GNU General Public License for more details.-
14-
15 You should have received a copy of the GNU General Public License-
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */-
17-
18/* Written by Jim Meyering. */-
19-
20#include <config.h>-
21#include <getopt.h>-
22#include <stdio.h>-
23#include <sys/types.h>-
24-
25#include "system.h"-
26#include "long-options.h"-
27#include "error.h"-
28#include "quote.h"-
29-
30/* The official name of this program (e.g., no 'g' prefix). */-
31#define PROGRAM_NAME "hostid"-
32-
33#define AUTHORS proper_name ("Jim Meyering")-
34-
35static struct option const long_options[] =-
36{-
37 {NULL, 0, NULL, 0}-
38};-
39-
40void-
41usage (int status)-
42{-
43 if (status != EXIT_SUCCESS)
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • hostid
FALSEevaluated 3 times by 1 test
Evaluated by:
  • hostid
3
44 emit_try_help ();
executed 3 times by 1 test: end of block
Executed by:
  • hostid
3
45 else-
46 {-
47 printf (_("\-
48Usage: %s [OPTION]\n\-
49Print the numeric identifier (in hexadecimal) for the current host.\n\-
50\n\-
51"), program_name);-
52 fputs (HELP_OPTION_DESCRIPTION, stdout);-
53 fputs (VERSION_OPTION_DESCRIPTION, stdout);-
54 emit_ancillary_info (PROGRAM_NAME);-
55 }
executed 3 times by 1 test: end of block
Executed by:
  • hostid
3
56 exit (status);
executed 6 times by 1 test: exit (status);
Executed by:
  • hostid
6
57}-
58-
59int-
60main (int argc, char **argv)-
61{-
62 unsigned int id;-
63-
64 initialize_main (&argc, &argv);-
65 set_program_name (argv[0]);-
66 setlocale (LC_ALL, "");-
67 bindtextdomain (PACKAGE, LOCALEDIR);-
68 textdomain (PACKAGE);-
69-
70 atexit (close_stdout);-
71-
72 parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,-
73 usage, AUTHORS, (char const *) NULL);-
74 if (getopt_long (argc, argv, "", long_options, NULL) != -1)
getopt_long (a...d *)0) ) != -1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • hostid
FALSEevaluated 1 time by 1 test
Evaluated by:
  • hostid
1-3
75 usage (EXIT_FAILURE);
executed 3 times by 1 test: usage ( 1 );
Executed by:
  • hostid
3
76-
77 if (optind < argc)
optind < argcDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • hostid
0-1
78 {-
79 error (0, 0, _("extra operand %s"), quote (argv[optind]));-
80 usage (EXIT_FAILURE);-
81 }
never executed: end of block
0
82-
83 id = gethostid ();-
84-
85 /* POSIX says gethostid returns a "32-bit identifier" but is silent-
86 whether it's sign-extended. Turn off any sign-extension. This-
87 is a no-op unless unsigned int is wider than 32 bits. */-
88 id &= 0xffffffff;-
89-
90 printf ("%08x\n", id);-
91-
92 return EXIT_SUCCESS;
executed 1 time by 1 test: return 0 ;
Executed by:
  • hostid
1
93}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2