summaryrefslogtreecommitdiff
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
commit73ae238801ac3d8e83af4fc10532837bdeace6d6 (patch)
tree5878a9cd6535d260b2b4f7b7deb7199fcdfb675e
parent9773d1df2db6131990bbcc678b1bb63bfcb2d02b (diff)
downloadsamba-73ae238801ac3d8e83af4fc10532837bdeace6d6.tar.gz
coding standards issue: should never compare a boolean expression == False
or == True. should always do if (boolean_expression). sorry. lkcl
-rw-r--r--source/nameelect.c98
1 files changed, 53 insertions, 45 deletions
diff --git a/source/nameelect.c b/source/nameelect.c
index 680b22378c4..b3251d8da63 100644
--- a/source/nameelect.c
+++ b/source/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);
+ }
+ }
+ }
}
- }
- }
}