Skip to content

Commit

Permalink
client: build without "using namespace std"
Browse files Browse the repository at this point in the history
* add "std::" prefix in headers
* add "using" declarations in .cc files.

so we don't rely on "using namespace std" in one or more included
headers.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Aug 13, 2021
1 parent 8c70de4 commit 4361b03
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/ceph_syn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <sys/types.h>
#include <fcntl.h>

using namespace std;

extern int syn_filer_flags;

int main(int argc, const char **argv, char *envp[])
Expand Down
1 change: 1 addition & 0 deletions src/client/SyntheticClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#undef dout_prefix
#define dout_prefix *_dout << "client." << (whoami >= 0 ? whoami:client->get_nodeid()) << " "

using namespace std;
// traces
//void trace_include(SyntheticClient *syn, Client *cl, string& prefix);
//void trace_openssh(SyntheticClient *syn, Client *cl, string& prefix);
Expand Down
56 changes: 28 additions & 28 deletions src/client/SyntheticClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@



void parse_syn_options(vector<const char*>& args);
void parse_syn_options(std::vector<const char*>& args);
extern int num_client;

class SyntheticClient {
Expand All @@ -109,11 +109,11 @@ class SyntheticClient {
int get_op();


filepath cwd;
map<string, struct stat*> contents;
set<string> subdirs;
bool did_readdir;
set<int> open_files;
filepath cwd;
std::map<std::string, struct stat*> contents;
std::set<std::string> subdirs;
bool did_readdir;
std::set<int> open_files;

void up();

Expand All @@ -125,7 +125,7 @@ class SyntheticClient {

int get_random_fh() {
int r = rand() % open_files.size();
set<int>::iterator it = open_files.begin();
std::set<int>::iterator it = open_files.begin();
while (r--) ++it;
return *it;
}
Expand All @@ -135,7 +135,7 @@ class SyntheticClient {
const char *get_random_subdir() {
ceph_assert(!subdirs.empty());
int r = ((rand() % subdirs.size()) + (rand() % subdirs.size())) / 2; // non-uniform distn
set<string>::iterator it = subdirs.begin();
std::set<std::string>::iterator it = subdirs.begin();
while (r--) ++it;

n1 = cwd;
Expand All @@ -150,7 +150,7 @@ class SyntheticClient {
r += cwd.last_dentry().c_str()[0]; // slightly permuted
r %= contents.size();

map<string,struct stat*>::iterator it = contents.begin();
std::map<std::string,struct stat*>::iterator it = contents.begin();
while (r--) ++it;

n2 = cwd;
Expand All @@ -162,7 +162,7 @@ class SyntheticClient {
char sub_s[50];
const char *make_sub(const char *base) {
snprintf(sub_s, sizeof(sub_s), "%s.%d", base, rand() % 100);
string f = sub_s;
std::string f = sub_s;
sub = cwd;
sub.push_dentry(f);
return sub.c_str();
Expand Down Expand Up @@ -191,16 +191,16 @@ class SyntheticClient {
}

// run() will do one of these things:
list<int> modes;
list<string> sargs;
list<int> iargs;
std::list<int> modes;
std::list<std::string> sargs;
std::list<int> iargs;
utime_t run_start;
utime_t run_until;

client_t run_only;
client_t exclude;

string get_sarg(int seq);
std::string get_sarg(int seq);
int get_iarg() {
int i = iargs.front();
iargs.pop_front();
Expand All @@ -209,24 +209,24 @@ class SyntheticClient {

bool time_to_stop() {
utime_t now = ceph_clock_now();
if (0) cout << "time_to_stop .. now " << now
<< " until " << run_until
<< " start " << run_start
<< std::endl;
if (0) std::cout << "time_to_stop .. now " << now
<< " until " << run_until
<< " start " << run_start
<< std::endl;
if (run_until.sec() && now > run_until)
return true;
else
return false;
}

string compose_path(string& prefix, char *rest) {
std::string compose_path(std::string& prefix, char *rest) {
return prefix + rest;
}

int full_walk(string& fromdir);
int full_walk(std::string& fromdir);
int random_walk(int n);

int dump_placement(string& fn);
int dump_placement(std::string& fn);


int make_dirs(const char *basedir, int dirs, int files, int depth);
Expand All @@ -238,8 +238,8 @@ class SyntheticClient {
int create_shared(int num);
int open_shared(int num, int count);

int rm_file(string& fn);
int write_file(string& fn, int mb, loff_t chunk);
int rm_file(std::string& fn);
int write_file(std::string& fn, int mb, loff_t chunk);
int write_fd(int fd, int size, int wrsize);

int write_batch(int nfile, int mb, int chunk);
Expand All @@ -249,15 +249,15 @@ class SyntheticClient {
int object_rw(int nobj, int osize, int wrpc, int overlap,
double rskew, double wskew);

int read_random(string& fn, int mb, int chunk);
int read_random_ex(string& fn, int mb, int chunk);
int read_random(std::string& fn, int mb, int chunk);
int read_random_ex(std::string& fn, int mb, int chunk);

int overload_osd_0(int n, int sie, int wrsize);
int check_first_primary(int fd);

int clean_dir(string& basedir);
int clean_dir(std::string& basedir);

int play_trace(Trace& t, string& prefix, bool metadata_only=false);
int play_trace(Trace& t, std::string& prefix, bool metadata_only=false);

void make_dir_mess(const char *basedir, int n);
void foo();
Expand All @@ -270,7 +270,7 @@ class SyntheticClient {
const UserPerm& perms);
int lookup_ino(inodeno_t ino, const UserPerm& perms);

int chunk_file(string &filename);
int chunk_file(std::string &filename);

void mksnap(const char *base, const char *name, const UserPerm& perms);
void rmsnap(const char *base, const char *name, const UserPerm& perms);
Expand Down
2 changes: 2 additions & 0 deletions src/client/fuse_ll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))

using namespace std;

static const ceph::unordered_map<int,int> cephfs_errno_to_system_errno = {
{CEPHFS_EBLOCKLISTED, ESHUTDOWN},
{CEPHFS_EPERM, EPERM},
Expand Down
4 changes: 2 additions & 2 deletions src/include/Distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <vector>

class Distribution {
vector<float> p;
vector<int> v;
std::vector<float> p;
std::vector<int> v;

public:
//Distribution() {
Expand Down

0 comments on commit 4361b03

Please sign in to comment.