Skip to content

Commit

Permalink
general: beautified code
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Sep 7, 2018
1 parent 37e292d commit b6546a4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
7 changes: 5 additions & 2 deletions core/src/filed/filed_conf.cc
Expand Up @@ -263,8 +263,11 @@ static void ParseConfigCb(LEX *lc, ResourceItem *item, int index, int pass)

static void ConfigReadyCallback(ConfigurationParser &my_config)
{
std::map<int, std::string> map{
{R_DIRECTOR, "R_DIRECTOR"}, {R_CLIENT, "R_CLIENT"}, {R_STORAGE, "R_STORAGE"}, {R_MSGS, "R_MSGS"}, {R_JOB, "R_JOB"}};
std::map<int, std::string> map{{R_DIRECTOR, "R_DIRECTOR"},
{R_CLIENT, "R_CLIENT"},
{R_STORAGE, "R_STORAGE"},
{R_MSGS, "R_MSGS"},
{R_JOB, "R_JOB"}};
my_config.InitializeQualifiedResourceNameTypeConverter(map);
}

Expand Down
24 changes: 8 additions & 16 deletions core/src/lib/jcr.cc
Expand Up @@ -179,8 +179,7 @@ uint64_t WriteLastJobsList(int fd, uint64_t addr)
Pmsg1(000, "Error writing num_items: ERR=%s\n", be.bstrerror());
goto bail_out;
}
foreach_dlist(je, last_jobs)
{
foreach_dlist (je, last_jobs) {
if (write(fd, je, sizeof(struct s_last_job)) != sizeof(struct s_last_job)) {
BErrNo be;
Pmsg1(000, "Error writing job: ERR=%s\n", be.bstrerror());
Expand Down Expand Up @@ -714,8 +713,7 @@ JobControlRecord *get_jcr_by_id(uint32_t JobId)
{
JobControlRecord *jcr;

foreach_jcr(jcr)
{
foreach_jcr (jcr) {
if (jcr->JobId == JobId) {
jcr->IncUseCount();
Dmsg3(debuglevel, "Inc get_jcr jid=%u UseCount=%d Job=%s\n", jcr->JobId, jcr->UseCount(), jcr->Job);
Expand All @@ -738,8 +736,7 @@ uint32_t GetJobidFromTid(pthread_t tid)
JobControlRecord *jcr = nullptr;
bool found = false;

foreach_jcr(jcr)
{
foreach_jcr (jcr) {
if (pthread_equal(jcr->my_thread_id, tid)) {
found = true;
break;
Expand All @@ -762,8 +759,7 @@ JobControlRecord *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime)
{
JobControlRecord *jcr;

foreach_jcr(jcr)
{
foreach_jcr (jcr) {
if (jcr->VolSessionId == SessionId && jcr->VolSessionTime == SessionTime) {
jcr->IncUseCount();
Dmsg3(debuglevel, "Inc get_jcr jid=%u UseCount=%d Job=%s\n", jcr->JobId, jcr->UseCount(), jcr->Job);
Expand All @@ -790,8 +786,7 @@ JobControlRecord *get_jcr_by_partial_name(char *Job)
if (!Job) { return nullptr; }

len = strlen(Job);
foreach_jcr(jcr)
{
foreach_jcr (jcr) {
if (bstrncmp(Job, jcr->Job, len)) {
jcr->IncUseCount();
Dmsg3(debuglevel, "Inc get_jcr jid=%u UseCount=%d Job=%s\n", jcr->JobId, jcr->UseCount(), jcr->Job);
Expand All @@ -815,8 +810,7 @@ JobControlRecord *get_jcr_by_full_name(char *Job)

if (!Job) { return nullptr; }

foreach_jcr(jcr)
{
foreach_jcr (jcr) {
if (bstrcmp(jcr->Job, Job)) {
jcr->IncUseCount();
Dmsg3(debuglevel, "Inc get_jcr jid=%u UseCount=%d Job=%s\n", jcr->JobId, jcr->UseCount(), jcr->Job);
Expand All @@ -834,8 +828,7 @@ const char *JcrGetAuthenticateKey(uint32_t job_id, const char *unified_job_name)

JobControlRecord *jcr;
const char *auth_key;
foreach_jcr(jcr)
{
foreach_jcr (jcr) {
if (bstrcmp(jcr->Job, unified_job_name)) {
auth_key = jcr->sd_auth_key;
Dmsg3(debuglevel, "Inc get_jcr jid=%u UseCount=%d Job=%s\n", jcr->JobId, jcr->UseCount(), jcr->Job);
Expand Down Expand Up @@ -1139,8 +1132,7 @@ static void JcrTimeoutCheck(watchdog_t *self)
/* Walk through all JCRs checking if any one is
* blocked for more than specified max time.
*/
foreach_jcr(jcr)
{
foreach_jcr (jcr) {
Dmsg2(debuglevel, "JcrTimeoutCheck JobId=%u jcr=0x%x\n", jcr->JobId, jcr);
if (jcr->JobId == 0) { continue; }
bs = jcr->store_bsock;
Expand Down
9 changes: 3 additions & 6 deletions core/src/lib/res.cc
Expand Up @@ -1788,8 +1788,7 @@ bool BareosResource::PrintConfig(PoolMem &buff, bool hide_sensitive_data, bool v
list = *(items[i].alistvalue);

if (list != NULL) {
foreach_alist(value, list)
{
foreach_alist (value, list) {
/*
* If this is the default value skip it.
*/
Expand Down Expand Up @@ -1817,8 +1816,7 @@ bool BareosResource::PrintConfig(PoolMem &buff, bool hide_sensitive_data, bool v
IndentConfigItem(cfg_str, 1, temp.c_str(), inherited);

PmStrcpy(res_names, "");
foreach_alist(res, list)
{
foreach_alist (res, list) {
if (cnt) {
Mmsg(temp, ",\"%s\"", res->name);
} else {
Expand Down Expand Up @@ -1862,8 +1860,7 @@ bool BareosResource::PrintConfig(PoolMem &buff, bool hide_sensitive_data, bool v

Mmsg(temp, "%s = {\n", items[i].name);
IndentConfigItem(cfg_str, 1, temp.c_str(), inherited);
foreach_dlist(adr, addrs)
{
foreach_dlist (adr, addrs) {
char tmp[1024];

adr->BuildConfigString(tmp, sizeof(tmp));
Expand Down
11 changes: 7 additions & 4 deletions core/src/stored/stored_conf.cc
Expand Up @@ -518,10 +518,13 @@ static void ParseConfigCb(LEX *lc, ResourceItem *item, int index, int pass)

static void ConfigReadyCallback(ConfigurationParser &my_config)
{
std::map<int, std::string> map{
{R_DIRECTOR, "R_DIRECTOR"}, {R_JOB, "R_JOB"}, /* needed for client name conversion */
{R_NDMP, "R_NDMP"}, {R_STORAGE, "R_STORAGE"}, {R_MSGS, "R_MSGS"},
{R_DEVICE, "R_DEVICE"}, {R_AUTOCHANGER, "R_AUTOCHANGER"}};
std::map<int, std::string> map{{R_DIRECTOR, "R_DIRECTOR"},
{R_JOB, "R_JOB"}, /* needed for client name conversion */
{R_NDMP, "R_NDMP"},
{R_STORAGE, "R_STORAGE"},
{R_MSGS, "R_MSGS"},
{R_DEVICE, "R_DEVICE"},
{R_AUTOCHANGER, "R_AUTOCHANGER"}};
my_config.InitializeQualifiedResourceNameTypeConverter(map);
}

Expand Down

0 comments on commit b6546a4

Please sign in to comment.