Closed Bug 289052 Opened 19 years ago Closed 19 years ago

debug_mode causes bugs

Categories

(NSPR :: NSPR, defect)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: lvcipriani, Assigned: shanmus)

Details

Attachments

(1 file, 1 obsolete file)

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
Shanmu, could you take a look at this?
Assignee: wtchang → shanmus
Status: NEW → ASSIGNED
Attached patch Patch to fix this. (obsolete) — Splinter Review
All the dangling else statements are fixed, except the one reported in ntioto.c
(which was already fixed).
Wan-Teh, can you review this fix?
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+
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
Status: ASSIGNED → RESOLVED
Closed: 19 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.

Attachment

General

Creator:
Created:
Updated:
Size: