Last Comment Bug 289052 - debug_mode causes bugs
: debug_mode causes bugs
Status: RESOLVED FIXED
:
Product: NSPR
Classification: Components
Component: NSPR (show other bugs)
: other
: All All
: -- minor (vote)
: 4.6.1
Assigned To: Shanmu
: Wan-Teh Chang
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-04-04 19:35 PDT by lvcipriani
Modified: 2005-06-29 11:08 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Patch to fix this. (6.70 KB, patch)
2005-06-07 05:11 PDT, Shanmu
wtc: review+
Details | Diff | Review
Patch as checked in (6.97 KB, patch)
2005-06-29 11:05 PDT, Wan-Teh Chang
no flags Details | Diff | Review

Description lvcipriani 2005-04-04 19:35:08 PDT
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
Comment 1 Boris Zbarsky [:bz] 2005-05-13 10:51:18 PDT
Over to NSPR...
Comment 2 Wan-Teh Chang 2005-05-19 12:07:22 PDT
Shanmu, could you take a look at this?
Comment 3 Shanmu 2005-06-07 05:11:29 PDT
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).
Comment 4 Shanmu 2005-06-28 23:08:08 PDT
Wan-Teh, can you review this fix?
Comment 5 Wan-Teh Chang 2005-06-29 09:57:37 PDT
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.
Comment 6 Wan-Teh Chang 2005-06-29 11:05:04 PDT
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

Note You need to log in before you can comment on or make changes to this bug.