debug_mode causes bugs

RESOLVED FIXED in 4.6.1

Status

NSPR
NSPR
--
minor
RESOLVED FIXED
12 years ago
12 years ago

People

(Reporter: lvcipriani, Assigned: Shanmu)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2

mozilla/nsprpub/pr/tests/ntioto.c: dangling else near line 141

    if ( bytesRead == -1 && PR_GetError() == PR_IO_TIMEOUT_ERROR )
        if ( debug ) printf("AcceptRead timed out\n");
    else
        if ( debug ) printf("Oops! read: %d, error: %d\n", bytesRead, 
PR_GetError());

probably should be:

    if ( bytesRead == -1 && PR_GetError() == PR_IO_TIMEOUT_ERROR ) {
        if ( debug ) printf("AcceptRead timed out\n");
	} else {
        if ( debug ) printf("Oops! read: %d, error: %d\n", bytesRead, 
PR_GetError());
	}

----------------------------------------------------------------------
mozilla/nsprpub/pr/tests/server_test.c: dangling else near line 235
                if (!WorkerThread)
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }
probably should be:
                if (!WorkerThread) {
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                } else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/server_test.c: dangling else near line 265

        if (bytesWritten != _server_data)
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
        else
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);

probably should be:

        if (bytesWritten != _server_data) {
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
		} else {
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);
		}

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/servr_kk.c: dangling else near line 201

                if (!WorkerThread)
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

probably should be:

                if (!WorkerThread) {
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                } else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/servr_kk.c: dangling else near line 231

        if (bytesWritten != _server_data)
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
        else
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);

probably should be:

        if (bytesWritten != _server_data) {
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
		} else {
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);
		}

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/servr_ku.c: dangling else near line 202

                if (!WorkerThread)
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

probably should be:

                if (!WorkerThread) {
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                } else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/servr_ku.c: dangling else near line 232

        if (bytesWritten != _server_data)
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
        else
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);

probably should be:

        if (bytesWritten != _server_data) {
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
        } else {
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);
		}

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/servr_uk.c: dangling else near line 204

                if (!WorkerThread)
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

probably should be:

                if (!WorkerThread) {
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                } else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/servr_uk.c: dangling else near line 234

        if (bytesWritten != _server_data)
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
        else
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);

probably should be:

        if (bytesWritten != _server_data) {
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
        } else {
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);
		}

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/servr_uu.c: dangling else near line 202

                if (!WorkerThread)
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

probably should be:

                if (!WorkerThread) {
                    if (debug_mode) printf("Error creating client 
thread %d\n", workerThreads);
                } else {
                    PR_AtomicIncrement(&workerThreads);
                    if (debug_mode) DPRINTF("\tServer creates worker 
(%d)\n", workerThreads);
                }

----------------------------------------------------------------------

mozilla/nsprpub/pr/tests/servr_uu.c: dangling else near line 232

        if (bytesWritten != _server_data)
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
        else
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);

probably should be:

        if (bytesWritten != _server_data) {
            if (debug_mode) printf("\tError sending data to client (%d, 
%d)\n", 
                bytesWritten, PR_GetOSError());
        } else {
            if (debug_mode) DPRINTF("\tServer sent %d bytes\n", 
bytesWritten);
		}

----------------------------------------------------------------------


Reproducible: Always
Over to NSPR...
Assignee: general → wtchang
Status: UNCONFIRMED → NEW
Component: General → NSPR
Ever confirmed: true
Product: Mozilla Application Suite → NSPR
QA Contact: general → wtchang
Version: unspecified → other

Comment 2

12 years ago
Shanmu, could you take a look at this?
Assignee: wtchang → shanmus
(Assignee)

Updated

12 years ago
Status: NEW → ASSIGNED
(Assignee)

Comment 3

12 years ago
Created attachment 185551 [details] [diff] [review]
Patch to fix this.

All the dangling else statements are fixed, except the one reported in ntioto.c
(which was already fixed).
(Assignee)

Comment 4

12 years ago
Wan-Teh, can you review this fix?

Comment 5

12 years ago
Comment on attachment 185551 [details] [diff] [review]
Patch to fix this.

r=wtc.

The indentation of the first "} else {" in server_test.c
seems to be off.  The other instances of "} else {" seem
to be off by one character.
Attachment #185551 - Flags: review+

Comment 6

12 years ago
Created attachment 187683 [details] [diff] [review]
Patch as checked in

I fixed the indentation problems in Shanmu's patch
and checked it in on the NSPR trunk for NSPR 4.6.1.

(Shanmu: it is best to avoid using tabs in NSPR code
unless the code you are modifying uses tabs.  In that
case, you should use tabs in the same way the existing
code uses them.)

Checking in server_test.c;
/cvsroot/mozilla/nsprpub/pr/tests/server_test.c,v  <--	server_test.c
new revision: 3.10; previous revision: 3.9
done
Checking in servr_kk.c;
/cvsroot/mozilla/nsprpub/pr/tests/servr_kk.c,v	<--  servr_kk.c
new revision: 3.12; previous revision: 3.11
done
Checking in servr_ku.c;
/cvsroot/mozilla/nsprpub/pr/tests/servr_ku.c,v	<--  servr_ku.c
new revision: 3.11; previous revision: 3.10
done
Checking in servr_uk.c;
/cvsroot/mozilla/nsprpub/pr/tests/servr_uk.c,v	<--  servr_uk.c
new revision: 3.11; previous revision: 3.10
done
Checking in servr_uu.c;
/cvsroot/mozilla/nsprpub/pr/tests/servr_uu.c,v	<--  servr_uu.c
new revision: 3.11; previous revision: 3.10
done
Attachment #185551 - Attachment is obsolete: true

Updated

12 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.6.1
You need to log in before you can comment on or make changes to this bug.