summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-05-22 19:08:56 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-05-22 19:08:56 +0000
commit5eb73eeea34e66e06db95f6f5efa87bd87a85bad (patch)
treea053b4d18e4089c630ff71d9b4ca5b0eb46defdc /source3
parent49f6320cf668c7baafdf63c0a1aa6f8576382702 (diff)
downloadsamba-5eb73eeea34e66e06db95f6f5efa87bd87a85bad.tar.gz
samba-5eb73eeea34e66e06db95f6f5efa87bd87a85bad.tar.bz2
samba-5eb73eeea34e66e06db95f6f5efa87bd87a85bad.zip
coding standards issue: should never compare a boolean expression == False
or == True. should always do if (boolean_expression). sorry. lkcl (This used to be commit 73ae238801ac3d8e83af4fc10532837bdeace6d6)
Diffstat (limited to 'source3')
-rw-r--r--source3/nameelect.c98
1 files changed, 53 insertions, 45 deletions
diff --git a/source3/nameelect.c b/source3/nameelect.c
index 680b22378c..b3251d8da6 100644
--- a/source3/nameelect.c
+++ b/source3/nameelect.c
@@ -699,9 +699,9 @@ static BOOL win_election(struct work_record *work,int version,uint32 criterion,
int mytimeup = time(NULL) - StartupTime;
uint32 mycriterion = work->ElectionCriterion;
- /* If local master is set to false then never win
+ /* If local master is false then never win
in election broadcasts. */
- if(lp_local_master() == False)
+ if(!lp_local_master())
{
DEBUG(3,("win_election: Losing election as local master == False\n"));
return False;
@@ -735,53 +735,61 @@ static BOOL win_election(struct work_record *work,int version,uint32 criterion,
******************************************************************/
void process_election(struct packet_struct *p,char *buf)
{
- struct dgram_packet *dgram = &p->packet.dgram;
- struct in_addr ip = dgram->header.source_ip;
- struct subnet_record *d = find_subnet(ip);
- int version = CVAL(buf,0);
- uint32 criterion = IVAL(buf,1);
- int timeup = IVAL(buf,5)/1000;
- char *name = buf+13;
- struct work_record *work;
+ struct dgram_packet *dgram = &p->packet.dgram;
+ struct in_addr ip = dgram->header.source_ip;
+ struct subnet_record *d = find_subnet(ip);
+ int version = CVAL(buf,0);
+ uint32 criterion = IVAL(buf,1);
+ int timeup = IVAL(buf,5)/1000;
+ char *name = buf+13;
+ struct work_record *work;
+
+ if (!d) return;
+
+ if (ip_equal(d->bcast_ip,wins_ip))
+ {
+ DEBUG(3,("Unexpected election request from %s %s on WINS net\n",
+ name, inet_ntoa(p->ip)));
+ return;
+ }
- if (!d) return;
+ name[15] = 0;
- if (ip_equal(d->bcast_ip,wins_ip)) {
- DEBUG(3,("Unexpected election request from %s %s on WINS net\n",
- name, inet_ntoa(p->ip)));
- return;
- }
-
- name[15] = 0;
+ DEBUG(3,("Election request from %s %s vers=%d criterion=%08x timeup=%d\n",
+ name,inet_ntoa(p->ip),version,criterion,timeup));
- DEBUG(3,("Election request from %s %s vers=%d criterion=%08x timeup=%d\n",
- name,inet_ntoa(p->ip),version,criterion,timeup));
-
- if (same_context(dgram)) return;
-
- for (work = d->workgrouplist; work; work = work->next)
- {
- if (!strequal(work->work_group, myworkgroup))
- continue;
-
- if (win_election(work, version,criterion,timeup,name)) {
- if (!work->RunningElection) {
- work->needelection = True;
- work->ElectionCount=0;
- work->mst_state = MST_POTENTIAL;
- }
- } else {
- work->needelection = False;
-
- if (work->RunningElection || AM_MASTER(work)) {
- work->RunningElection = False;
- DEBUG(3,(">>> Lost election on %s %s <<<\n",
- work->work_group,inet_ntoa(d->bcast_ip)));
- if (AM_MASTER(work))
- unbecome_local_master(d, work, SV_TYPE_MASTER_BROWSER);
+ if (same_context(dgram)) return;
+
+ for (work = d->workgrouplist; work; work = work->next)
+ {
+ if (!strequal(work->work_group, myworkgroup))
+ continue;
+
+ if (win_election(work, version,criterion,timeup,name))
+ {
+ if (!work->RunningElection)
+ {
+ work->needelection = True;
+ work->ElectionCount=0;
+ work->mst_state = MST_POTENTIAL;
+ }
+ }
+ else
+ {
+ work->needelection = False;
+
+ if (work->RunningElection || AM_MASTER(work))
+ {
+ work->RunningElection = False;
+ DEBUG(3,(">>> Lost election on %s %s <<<\n",
+ work->work_group,inet_ntoa(d->bcast_ip)));
+ if (AM_MASTER(work))
+ {
+ unbecome_local_master(d, work, SV_TYPE_MASTER_BROWSER);
+ }
+ }
+ }
}
- }
- }
}