1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
From 4f60ce245b3cfe2117fdaf00a9e74a49f769daca Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Mon, 22 Feb 2021 16:03:21 -0800
Subject: [PATCH] remove using namespace std
Fixes: warning: using directive refers to implicitly-defined namespace 'std'
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
bon_time.cpp | 8 ++++----
bonnie++.cpp | 8 ++++----
bonnie.h | 2 --
duration.cpp | 4 +---
getc_putc.cpp | 2 +-
rand.cpp | 4 ++--
rand.h | 5 ++---
7 files changed, 14 insertions(+), 19 deletions(-)
--- a/bon_time.cpp
+++ b/bon_time.cpp
@@ -26,12 +26,12 @@ void BonTimer::add_delta_report(report_s
}
else
{
- m_delta[test].FirstStart = min(m_delta[test].FirstStart, rep.StartTime);
- m_delta[test].LastStop = max(m_delta[test].LastStop, rep.EndTime);
+ m_delta[test].FirstStart = std::min(m_delta[test].FirstStart, rep.StartTime);
+ m_delta[test].LastStop = std::max(m_delta[test].LastStop, rep.EndTime);
}
m_delta[test].CPU += rep.CPU;
m_delta[test].Elapsed = m_delta[test].LastStop - m_delta[test].FirstStart;
- m_delta[test].Latency = max(m_delta[test].Latency, rep.Latency);
+ m_delta[test].Latency = std::max(m_delta[test].Latency, rep.Latency);
}
BonTimer::BonTimer()
@@ -56,7 +56,7 @@ BonTimer::Initialize()
void
BonTimer::add_latency(tests_t test, double t)
{
- m_delta[test].Latency = max(m_delta[test].Latency, t);
+ m_delta[test].Latency = std::max(m_delta[test].Latency, t);
}
int BonTimer::print_cpu_stat(tests_t test)
--- a/bonnie++.cpp
+++ b/bonnie++.cpp
@@ -75,7 +75,7 @@ public:
void set_io_chunk_size(int size)
{ delete m_buf; pa_new(size, m_buf, m_buf_pa); m_io_chunk_size = size; }
void set_file_chunk_size(int size)
- { delete m_buf; m_buf = new char[max(size, m_io_chunk_size)]; m_file_chunk_size = size; }
+ { delete m_buf; m_buf = new char[std::max(size, m_io_chunk_size)]; m_file_chunk_size = size; }
// Return the page-aligned version of the local buffer
char *buf() { return m_buf_pa; }
@@ -142,7 +142,7 @@ CGlobalItems::CGlobalItems(bool *exitFla
, m_buf(NULL)
, m_buf_pa(NULL)
{
- pa_new(max(m_io_chunk_size, m_file_chunk_size), m_buf, m_buf_pa);
+ pa_new(std::max(m_io_chunk_size, m_file_chunk_size), m_buf, m_buf_pa);
SetName(".");
}
@@ -407,8 +407,8 @@ int main(int argc, char *argv[])
usage();
}
#endif
- globals.byte_io_size = min(file_size, globals.byte_io_size);
- globals.byte_io_size = max(0, globals.byte_io_size);
+ globals.byte_io_size = std::min(file_size, globals.byte_io_size);
+ globals.byte_io_size = std::max(0, globals.byte_io_size);
if(machine == NULL)
{
--- a/bonnie.h
+++ b/bonnie.h
@@ -1,8 +1,6 @@
#ifndef BONNIE
#define BONNIE
-using namespace std;
-
#define BON_VERSION "2.00"
#define CSV_VERSION "1.98"
--- a/duration.cpp
+++ b/duration.cpp
@@ -1,5 +1,3 @@
-using namespace std;
-
#include <stdlib.h>
#include "duration.h"
@@ -38,7 +36,7 @@ double Duration_Base::stop()
getTime(&tv);
double ret;
ret = tv - m_start;
- m_max = max(m_max, ret);
+ m_max = std::max(m_max, ret);
return ret;
}
--- a/getc_putc.cpp
+++ b/getc_putc.cpp
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
int size = 0, wrote;
while(size < file_size)
{
- wrote = write(FILE_FD, buf, min(sizeof(buf), (size_t)file_size - size));
+ wrote = write(FILE_FD, buf, std::min(sizeof(buf), (size_t)file_size - size));
if(wrote < 0)
{
fprintf(stderr, "Can't extend file - disk full?\n");
--- a/rand.cpp
+++ b/rand.cpp
@@ -31,7 +31,7 @@ bool Rand::seedFile(CPCCHAR name)
}
close(fd);
m_ind = -1;
- m_name = string(name);
+ m_name = std::string(name);
return false;
}
@@ -44,7 +44,7 @@ void Rand::seedNum(UINT num)
m_init = num;
char buf[12];
sprintf(buf, "%u", num);
- m_name = string(buf);
+ m_name = std::string(buf);
}
void Rand::reset()
--- a/rand.h
+++ b/rand.h
@@ -1,7 +1,6 @@
#ifndef RAND_H
#define RAND_H
-using namespace std;
#include "port.h"
#include <string>
#include <stdio.h>
@@ -31,7 +30,7 @@ public:
int getSize() { return m_size; }
- string getSeed() { return m_name; }
+ std::string getSeed() { return m_name; }
void reset();
@@ -39,7 +38,7 @@ private:
int *m_arr;
int m_size;
int m_ind;
- string m_name;
+ std::string m_name;
UINT m_init;
Rand(const Rand &t);
|