Skip to content

Commit af25522

Browse files
authored
Merge pull request #323 from deeglaze/remove_using_std
Remove using namespace std Signed-off-by: Zhang Lili Z <lili.z.zhang@intel.com>
2 parents a048cca + 1cd5340 commit af25522

File tree

22 files changed

+110
-137
lines changed

22 files changed

+110
-137
lines changed

common/src/sgx_profile.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@
3838
#include "sgx_profile.h"
3939
#include "se_time.h"
4040
#include <string.h>
41-
using namespace std;
4241

4342
typedef struct _profile_item_t{
4443
const char *str; /* tag */
4544
int flag; /* 0: start, 1: end */
4645
long long time; /* current time */
4746
} profile_item_t;
4847

49-
static vector<profile_item_t> profile_items;
48+
static std::vector<profile_item_t> profile_items;
5049
static int alloc_size;
5150
static int used_size;
5251
const int MALLOC_SIZE = 1000;
@@ -108,7 +107,7 @@ extern "C" void profile_output(const char* filename)
108107
{
109108
int i,j;
110109

111-
ofstream fs;
110+
std::ofstream fs;
112111
fs.open(filename); /* do not overwritten previous value */
113112

114113
fs << "freq: " << freq <<endl;

psw/ae/aesm_service/source/aesm_wrapper/inc/CAESMServer.h

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#include "AESMQueueManager.h"
4040
#include <stdexcept>
4141

42-
using namespace std;
43-
4442
/*
4543
* Encapsulates all AESM server logic
4644
*/

psw/ae/aesm_service/source/oal/internal_log.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ static ae_error_t init_log_file(void)
5959
}
6060

6161
#include <string>
62-
using namespace std;
6362

6463
static const char *get_sgx_status_t_string(sgx_status_t status);
6564
static const char *get_ae_error_t_string(ae_error_t ae_error);

psw/ae/aesm_service/source/upse/interface_psda.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
#define BREAK_IF_TRUE(x, Sts, ErrCode) if (x) { Sts = ErrCode; break; }
4545
#define BREAK_IF_FALSE(x, Sts, ErrCode) if (!(x)) { Sts = ErrCode; break; }
4646

47-
using namespace std;
48-
49-
5047
static JVM_COMM_BUFFER commBuf_s1, commBuf_s3;
5148
static INT32 responseCode;
5249

psw/urts/enclave.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
#include "rts.h"
4646

4747

48-
using namespace std;
49-
5048
int do_ecall(const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread);
5149
int do_ocall(const bridge_fn_t bridge, void *ms);
5250

psw/urts/linux/misc.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
#include <dirent.h>
3535
#include <vector>
3636

37-
using namespace std;
38-
3937
//get all thread id of current process.
40-
void get_thread_set(vector<se_thread_id_t> &thread_vector)
38+
void get_thread_set(std::vector<se_thread_id_t> &thread_vector)
4139
{
4240
DIR* dir = NULL;
4341
struct dirent* dirent = NULL;

psw/urts/loader.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void* CLoader::get_symbol_address(const char * const symbol)
103103
}
104104

105105
// is_relocation_page returns true if the specified RVA is a writable relocation page based on the bitmap.
106-
bool CLoader::is_relocation_page(const uint64_t rva, vector<uint8_t> *bitmap)
106+
bool CLoader::is_relocation_page(const uint64_t rva, std::vector<uint8_t> *bitmap)
107107
{
108108
uint64_t page_frame = rva >> SE_PAGE_SHIFT;
109109
//NOTE:
@@ -181,7 +181,7 @@ int CLoader::build_mem_region(const section_info_t &sec_info)
181181
return SGX_SUCCESS;
182182
}
183183

184-
int CLoader::build_sections(vector<uint8_t> *bitmap)
184+
int CLoader::build_sections(std::vector<uint8_t> *bitmap)
185185
{
186186
int ret = SGX_SUCCESS;
187187
std::vector<Section*> sections = m_parser.get_sections();
@@ -372,7 +372,7 @@ int CLoader::build_context(const uint64_t start_rva, layout_entry_t *layout)
372372
ptcs->ogs_base += rva;
373373
if(!(attributes & PAGE_ATTR_EREMOVE))
374374
{
375-
m_tcs_list.push_back(make_pair(GET_PTR(tcs_t, m_start_addr, rva), false));
375+
m_tcs_list.push_back(std::make_pair(GET_PTR(tcs_t, m_start_addr, rva), false));
376376
}
377377
sinfo.flags = layout->si_flags;
378378
if(SGX_SUCCESS != (ret = build_pages(rva, ((uint64_t)layout->page_count) << SE_PAGE_SHIFT, added_page, sinfo, attributes)))
@@ -417,7 +417,7 @@ int CLoader::build_context(const uint64_t start_rva, layout_entry_t *layout)
417417
#ifndef SE_SIM
418418
if(layout->id == LAYOUT_ID_TCS_DYN)
419419
{
420-
m_tcs_list.push_back(make_pair(GET_PTR(tcs_t, m_start_addr, rva), true));
420+
m_tcs_list.push_back(std::make_pair(GET_PTR(tcs_t, m_start_addr, rva), true));
421421
}
422422
#endif
423423
}
@@ -486,7 +486,7 @@ int CLoader::build_image(SGXLaunchToken * const lc, sgx_attributes_t * const sec
486486
// If load_enclave_ex try to load the enclave for the 2nd time,
487487
// the enclave image is already patched, and parser cannot read the information.
488488
// For linux, there's no map conflict. We assume load_enclave_ex will not do the retry.
489-
vector<uint8_t> bitmap;
489+
std::vector<uint8_t> bitmap;
490490
if(!m_parser.get_reloc_bitmap(bitmap))
491491
return SGX_ERROR_INVALID_ENCLAVE;
492492

@@ -564,12 +564,12 @@ int CLoader::validate_layout_table()
564564
{
565565
layout_t *layout_start = GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset);
566566
layout_t *layout_end = GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset + m_metadata->dirs[DIR_LAYOUT].size);
567-
vector<pair<uint64_t, uint64_t>> rva_vector;
567+
std::vector<std::pair<uint64_t, uint64_t>> rva_vector;
568568
for (layout_t *layout = layout_start; layout < layout_end; layout++)
569569
{
570570
if(!IS_GROUP_ID(layout->entry.id)) // layout entry
571571
{
572-
rva_vector.push_back(make_pair(layout->entry.rva, ((uint64_t)layout->entry.page_count) << SE_PAGE_SHIFT));
572+
rva_vector.push_back(std::make_pair(layout->entry.rva, ((uint64_t)layout->entry.page_count) << SE_PAGE_SHIFT));
573573
if(layout->entry.content_offset)
574574
{
575575
if(false == is_metadata_buffer(layout->entry.content_offset, layout->entry.content_size))
@@ -598,15 +598,15 @@ int CLoader::validate_layout_table()
598598
{
599599
return SGX_ERROR_INVALID_METADATA;
600600
}
601-
rva_vector.push_back(make_pair(entry->rva + load_step, ((uint64_t)entry->page_count) << SE_PAGE_SHIFT));
601+
rva_vector.push_back(std::make_pair(entry->rva + load_step, ((uint64_t)entry->page_count) << SE_PAGE_SHIFT));
602602
// no need to check integer overflow for entry->rva + load_step, because
603603
// entry->rva and load_step are less than enclave_size, whose size is no more than 37 bit
604604
}
605605
}
606606
}
607607
}
608608
sort(rva_vector.begin(), rva_vector.end());
609-
for (vector<pair<uint64_t, uint64_t>>::iterator it = rva_vector.begin(); it != rva_vector.end(); it++)
609+
for (std::vector<std::pair<uint64_t, uint64_t>>::iterator it = rva_vector.begin(); it != rva_vector.end(); it++)
610610
{
611611
if(!IS_PAGE_ALIGNED(it->first))
612612
{

psw/urts/loader.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class CLoader: private Uncopyable
7777
int build_contexts(layout_t *layout_start, layout_t *layout_end, uint64_t delta);
7878
int build_partial_page(const uint64_t rva, const uint64_t size, const void *source, const sec_info_t &sinfo, const uint32_t attr);
7979
int build_pages(const uint64_t start_rva, const uint64_t size, const void *source, const sec_info_t &sinfo, const uint32_t attr);
80-
bool is_relocation_page(const uint64_t rva, vector<uint8_t> *bitmap);
80+
bool is_relocation_page(const uint64_t rva, std::vector<uint8_t> *bitmap);
8181

8282
bool is_ae(const enclave_css_t *enclave_css);
8383
bool is_metadata_buffer(uint32_t offset, uint32_t size);
@@ -86,7 +86,7 @@ class CLoader: private Uncopyable
8686
int validate_patch_table();
8787
int validate_metadata();
8888
int get_debug_flag(const token_t * const launch);
89-
virtual int build_sections(vector<uint8_t> *bitmap);
89+
virtual int build_sections(std::vector<uint8_t> *bitmap);
9090
int set_context_protection(layout_t *layout_start, layout_t *layout_end, uint64_t delta);
9191

9292
uint8_t *m_mapped_file_base;

psw/urts/parser/binparser.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
#include <stdint.h>
4242
#include <vector>
4343
#include <string>
44-
using std::vector;
45-
using std::string;
4644

4745
#define ENCLAVE_MAX_SIZE_32 0xffffffff
4846
#define ENCLAVE_MAX_SIZE_64 0x1fffffffff
@@ -77,17 +75,17 @@ class BinParser {
7775
virtual const uint8_t* get_start_addr() const = 0;
7876

7977
// Get a vector of sections to be loaded
80-
virtual const vector<Section *>& get_sections() const = 0;
78+
virtual const std::vector<Section *>& get_sections() const = 0;
8179

8280
// Get the TLS section
8381
virtual const Section* get_tls_section() const = 0;
8482

8583
virtual uint64_t get_symbol_rva(const char* name) const = 0;
8684

87-
virtual bool get_reloc_bitmap(vector<uint8_t> &bitmap) = 0;
85+
virtual bool get_reloc_bitmap(std::vector<uint8_t> &bitmap) = 0;
8886

8987
virtual void get_reloc_entry_offset(const char* sec_name,
90-
vector<uint64_t>& offsets) = 0;
88+
std::vector<uint64_t>& offsets) = 0;
9189

9290
// !We need to put this method into BinParser class since
9391
// !the `global_data_t' is platform-dependent as the parser.
@@ -107,7 +105,7 @@ class BinParser {
107105

108106
virtual sgx_status_t get_info(enclave_diff_info_t *enclave_diff_info) = 0;
109107

110-
virtual void get_executable_sections(vector<const char *>& xsec_names) const = 0;
108+
virtual void get_executable_sections(std::vector<const char *>& xsec_names) const = 0;
111109
virtual bool set_memory_protection(uint64_t enclave_base_addr, bool is_after_initialization) = 0;
112110
virtual void get_pages_to_protect(uint64_t, std::vector<std::tuple<uint64_t, uint64_t, uint32_t>>&) const = 0;
113111
virtual bool has_init_section() const = 0;

psw/urts/parser/elfparser.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool parse_dyn(const ElfW(Ehdr) *elf_hdr, ElfW(Dyn)* dyn_info)
184184
* We only need to search `.dynsym' for undefined symbols.
185185
*/
186186
bool check_symbol_table(const ElfW(Ehdr) *elf_hdr, const ElfW(Dyn) *dyn_info,
187-
map<string, uint64_t>& sym_table)
187+
std::map<std::string, uint64_t>& sym_table)
188188
{
189189
const ElfW(Shdr) *sh_symtab = get_section_by_addr(elf_hdr, dyn_info[DT_SYMTAB].d_un.d_ptr);
190190

@@ -245,7 +245,7 @@ bool check_symbol_table(const ElfW(Ehdr) *elf_hdr, const ElfW(Dyn) *dyn_info,
245245
// If the enclave if compiled/linked with -fpie/-pie, and setting the
246246
// enclave entry to `enclave_entry', the `st_name' for `enclave_entry'
247247
// will be 0 in `.dynsym'.
248-
map<string, uint64_t>::const_iterator it = sym_table.find("enclave_entry");
248+
std::map<std::string, uint64_t>::const_iterator it = sym_table.find("enclave_entry");
249249
if (it == sym_table.end())
250250
{
251251
sym_table["enclave_entry"] = (uint64_t)elf_hdr->e_entry;
@@ -504,7 +504,7 @@ Section* build_section(const uint8_t* raw_data, uint64_t size, uint64_t virtual_
504504
}
505505

506506
bool build_regular_sections(const uint8_t* start_addr,
507-
vector<Section *>& sections,
507+
std::vector<Section *>& sections,
508508
const Section*& tls_sec,
509509
uint64_t& metadata_offset,
510510
uint64_t& metadata_block_size)
@@ -565,7 +565,7 @@ bool build_regular_sections(const uint8_t* start_addr,
565565
return true;
566566
}
567567

568-
const Section* get_max_rva_section(const vector<Section*> sections)
568+
const Section* get_max_rva_section(const std::vector<Section*> sections)
569569
{
570570
size_t sec_size = sections.size();
571571

@@ -672,7 +672,7 @@ const uint8_t* ElfParser::get_start_addr() const
672672
return m_start_addr;
673673
}
674674

675-
const vector<Section *>& ElfParser::get_sections() const
675+
const std::vector<Section *>& ElfParser::get_sections() const
676676
{
677677
return m_sections;
678678
}
@@ -684,7 +684,7 @@ const Section* ElfParser::get_tls_section() const
684684

685685
uint64_t ElfParser::get_symbol_rva(const char* name) const
686686
{
687-
map<string, uint64_t>::const_iterator it = m_sym_table.find(name);
687+
std::map<std::string, uint64_t>::const_iterator it = m_sym_table.find(name);
688688
if (it != m_sym_table.end())
689689
return it->second;
690690
else
@@ -700,7 +700,7 @@ bool ElfParser::has_text_reloc() const
700700
return false;
701701
}
702702

703-
bool ElfParser::get_reloc_bitmap(vector<uint8_t>& bitmap)
703+
bool ElfParser::get_reloc_bitmap(std::vector<uint8_t>& bitmap)
704704
{
705705
// Clear the `bitmap' so that it is in a known state
706706
bitmap.clear();
@@ -781,7 +781,7 @@ bool ElfParser::get_reloc_bitmap(vector<uint8_t>& bitmap)
781781
return true;
782782
}
783783

784-
void ElfParser::get_reloc_entry_offset(const char* sec_name, vector<uint64_t>& offsets)
784+
void ElfParser::get_reloc_entry_offset(const char* sec_name, std::vector<uint64_t>& offsets)
785785
{
786786
if (sec_name == NULL)
787787
return;
@@ -859,7 +859,7 @@ sgx_status_t ElfParser::get_info(enclave_diff_info_t *enclave_diff_info)
859859
return SGX_SUCCESS;
860860
}
861861

862-
void ElfParser::get_executable_sections(vector<const char *>& xsec_names) const
862+
void ElfParser::get_executable_sections(std::vector<const char *>& xsec_names) const
863863
{
864864
xsec_names.clear();
865865

psw/urts/parser/elfparser.h

+13-16
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
#include <string>
4040
#include <map>
4141

42-
using std::map;
43-
using std::string;
44-
4542
class ElfParser : public BinParser, private Uncopyable {
4643
public:
4744
// The `start_addr' cannot be NULL
@@ -63,11 +60,11 @@ class ElfParser : public BinParser, private Uncopyable {
6360

6461
// The `section' here is a section in PE's concept.
6562
// It is in fact a `segment' in ELF's view.
66-
const vector<Section *>& get_sections() const;
63+
const std::vector<Section *>& get_sections() const;
6764
const Section* get_tls_section() const;
6865
uint64_t get_symbol_rva(const char* name) const;
6966

70-
bool get_reloc_bitmap(vector<uint8_t> &bitmap);
67+
bool get_reloc_bitmap(std::vector<uint8_t> &bitmap);
7168
bool has_text_reloc() const;
7269
uint32_t get_global_data_size();
7370
bool update_global_data(const metadata_t *const metadata,
@@ -86,11 +83,11 @@ class ElfParser : public BinParser, private Uncopyable {
8683
// To check whether current enclave has any TEXTREL:
8784
// get_reloc_entry_offset(".text", offsets);
8885
void get_reloc_entry_offset(const char* sec_name,
89-
vector<uint64_t>& offsets);
86+
std::vector<uint64_t>& offsets);
9087

9188
sgx_status_t modify_info(enclave_diff_info_t *enclave_diff_info);
9289
sgx_status_t get_info(enclave_diff_info_t *enclave_diff_info);
93-
void get_executable_sections(vector<const char *>& xsec_names) const;
90+
void get_executable_sections(std::vector<const char *>& xsec_names) const;
9491
bool is_enclave_encrypted() const;
9592

9693
bool set_memory_protection(uint64_t enclave_base_addr, bool is_after_initialization);
@@ -99,18 +96,18 @@ class ElfParser : public BinParser, private Uncopyable {
9996
bool has_init_section() const;
10097

10198
private:
102-
const uint8_t* m_start_addr;
103-
uint64_t m_len;
104-
bin_fmt_t m_bin_fmt;
105-
vector<Section *> m_sections;
106-
const Section* m_tls_section;
107-
uint64_t m_metadata_offset;
108-
uint64_t m_metadata_block_size;/*multiple metadata block size*/
99+
const uint8_t* m_start_addr;
100+
uint64_t m_len;
101+
bin_fmt_t m_bin_fmt;
102+
std::vector<Section *> m_sections;
103+
const Section* m_tls_section;
104+
uint64_t m_metadata_offset;
105+
uint64_t m_metadata_block_size;/*multiple metadata block size*/
109106

110-
ElfW(Dyn) m_dyn_info[DT_NUM + DT_ADDRNUM];
107+
ElfW(Dyn) m_dyn_info[DT_NUM + DT_ADDRNUM];
111108

112109
// A map from symbol name to its RVA
113-
map<string, uint64_t> m_sym_table;
110+
std::map<std::string, uint64_t> m_sym_table;
114111
};
115112

116113
#endif

psw/urts/section_info.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@
3636
#include "util.h"
3737
#include <vector>
3838

39-
using namespace std;
40-
4139
typedef struct _section_info_t
4240
{
4341
const uint8_t *raw_data; //The file pointer to the first page of the section.
4442
uint64_t raw_data_size; //The size of the section or the size of the initialized section on disk.
4543
uint64_t rva; //The address of the first byte of the section relative to the image base when section is loaded into memory.
4644
uint64_t virtual_size; //The total size of the section when loaded into memory.
4745
si_flags_t flag; //the attribute of memory region.
48-
vector<uint8_t> *bitmap; //bitmap of the total image page, if bit is 1, the page should be writable.
46+
std::vector<uint8_t> *bitmap; //bitmap of the total image page, if bit is 1, the page should be writable.
4947
//the first bit of scetion in the bitmap is bitmap[(rva >> PAGE_SHIFT) / 8] & (1 << ((rva >> PAGE_SHIFT) % 8))
5048
//if the bitmap is NULL, then no restrict on page attribute.
5149
} section_info_t;

0 commit comments

Comments
 (0)