Closed Bug 331299 Opened 14 years ago Closed 8 years ago

op_noacc.c: In function `main': 94: warning: control reaches end of non-void function

Categories

(NSPR :: NSPR, defect, P2, trivial)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: timeless, Assigned: atulagrwl)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [build_warning])

Attachments

(1 file, 3 obsolete files)

/Users/timeless/mozilla/nsprpub/pr/tests/op_noacc.c: In function `main':
/Users/timeless/mozilla/nsprpub/pr/tests/op_noacc.c:94: warning: control reaches end of non-void function
Attached patch oops. wrong bug (obsolete) — Splinter Review
Attachment #215857 - Flags: review?(wtchang)
Attachment #215857 - Attachment description: ifdef the rest of the file → oops. wrong bug
Attachment #215857 - Attachment is obsolete: true
Attachment #215857 - Flags: review?(wtchang)
Attached patch return fail more often? (obsolete) — Splinter Review
Attachment #215858 - Flags: review?(wtchang)
QA Contact: wtchang → nspr
Blocks: buildwarning
Whiteboard: [build_warning]
Current warnings:
/mozilla/mozilla-central/nsprpub/pr/tests/op_noacc.c: In function ‘main’:
/mozilla/mozilla-central/nsprpub/pr/tests/op_noacc.c:72:5: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
/mozilla/mozilla-central/nsprpub/pr/tests/op_noacc.c:82:1: warning: control reaches end of non-void function [-Wreturn-type]
Attached patch Patch v1 (obsolete) — Splinter Review
Assignee: wtc → atulagrwl
Attachment #215858 - Attachment is obsolete: true
Attachment #583861 - Flags: review?(benjamin)
Attachment #215858 - Flags: review?(wtc)
Comment on attachment 583861 [details] [diff] [review]
Patch v1

I am not an NSPR peer.
Attachment #583861 - Flags: review?(benjamin) → review?(wtc)
Comment on attachment 583861 [details] [diff] [review]
Patch v1

r=wtc.  Thanks for the patch.

>+    if (err01 == NULL) {
>+        if (PR_GetError() == PR_NO_ACCESS_RIGHTS_ERROR) {
>+            printf ("error code is %d\n",PR_GetError());
>+            printf ("PASS\n");
>+            return 0;
>+        }
>+    }

In this form, the nested if statements can be merged with &&:

    if (err01 == NULL && PR_GetError() == PR_NO_ACCESS_RIGHTS_ERROR) {
        printf ("error code is %d\n",PR_GetError());
        printf ("PASS\n");
        return 0;
    }

We can also attempt more cleanup.  For example, it may
make sense to print the error code whenever PR_Open fails.
In that form, we would need the nested if statements:

    if (err01 == NULL) {
        int error = PR_GetError();
        printf ("error code is %d\n", error);
        if (error == PR_NO_ACCESS_RIGHTS_ERROR) {
            printf ("PASS\n");
            return 0;
        }
    }
Attachment #583861 - Flags: review?(wtc) → review+
Attached patch Patch v1.01Splinter Review
Agreeing to all the changes suggested.
Attachment #583861 - Attachment is obsolete: true
Keywords: checkin-needed
Sorry this patch sat around so long, I checked it into NSPR CVS for you:
Checking in pr/tests/op_noacc.c;
/cvsroot/mozilla/nsprpub/pr/tests/op_noacc.c,v  <--  op_noacc.c
new revision: 3.10; previous revision: 3.9
done
Status: NEW → RESOLVED
Closed: 8 years ago
Keywords: checkin-needed
OS: Mac OS X → All
Hardware: PowerPC → All
Resolution: --- → FIXED
Version: other → 4.9.1
Thanks a lot Ted.
Priority: -- → P2
Target Milestone: --- → 4.9.1
Version: 4.9.1 → other
You need to log in before you can comment on or make changes to this bug.