Coverage Report

Created: 2025-11-09 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tpm2/Locality.c
Line
Count
Source
1
// This file was extracted from the TCG Published
2
// Trusted Platform Module Library
3
// Part 4: Supporting Routines
4
// Family "2.0"
5
// Level 00 Revision 01.16
6
// October 30, 2014
7
8
#include "InternalRoutines.h"
9
//
10
//
11
//           LocalityGetAttributes()
12
//
13
//     This function will convert a locality expressed as an integer into TPMA_LOCALITY form.
14
//     The function returns the locality attribute.
15
//
16
TPMA_LOCALITY
17
LocalityGetAttributes(
18
      UINT8               locality            // IN: locality value
19
      )
20
5
{
21
5
      TPMA_LOCALITY                 locality_attributes;
22
5
      BYTE                         *localityAsByte = (BYTE *)&locality_attributes;
23
5
      MemorySet(&locality_attributes, 0, sizeof(TPMA_LOCALITY));
24
5
      switch(locality)
25
5
      {
26
5
          case 0:
27
5
              locality_attributes.locZero = SET;
28
5
              break;
29
0
          case 1:
30
0
              locality_attributes.locOne = SET;
31
0
              break;
32
0
          case 2:
33
0
              locality_attributes.locTwo = SET;
34
0
              break;
35
0
          case 3:
36
0
              locality_attributes.locThree = SET;
37
0
              break;
38
0
          case 4:
39
0
              locality_attributes.locFour = SET;
40
0
              break;
41
0
          default:
42
0
              pAssert(locality > 31);
43
0
              *localityAsByte = locality;
44
0
              break;
45
5
      }
46
5
      return locality_attributes;
47
5
}