Closed Bug 950344 Opened 11 years ago Closed 9 years ago

Fix unused-but-set-variable 'client' warning in pkix_pl_httpdefaultclient.c

Categories

(NSS :: Libraries, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: vaduva.andrei.iustin, Assigned: vaduva.andrei.iustin)

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36

Steps to reproduce:

I found a build warning in 521:13.14 pkix_pl_httpdefaultclient.c: In function ‘pkix_pl_HttpDefaultClient_KeepAliveSession’:
521:13.16 pkix_pl_httpdefaultclient.c:1135:36: warning: variable ‘client’ set but not used [-Wunused-but-set-variable] - Andrei V
521:13.16          PKIX_PL_HttpDefaultClient *client = NULL;
521:13.16                                     ^

I intend to fix it.
Attached patch first_patch (obsolete) — Splinter Review
I moved line 1135 which was initialized with NULL to line 1147 and I initialized it with variable needed. This was my first bug fix.
Attachment #8347619 - Flags: review?(brian)
Comment on attachment 8347619 [details] [diff] [review]
first_patch

Review of attachment 8347619 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for the patch. Please make the improvements below.

::: security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_httpdefaultclient.c
@@ +1131,5 @@
>          SEC_HTTP_SERVER_SESSION session,
>          PRPollDesc **pPollDesc,
>          void *plContext)
>  {
> +       

Please remove both of these blank lines. (And note trailing whitespace.)

@@ +1143,5 @@
>                  PKIX_HTTPDEFAULTCLIENT_TYPE,
>                  plContext),
>                  PKIX_SESSIONNOTANHTTPDEFAULTCLIENT);
> + 		
> +	PKIX_PL_HttpDefaultClient *client = (PKIX_PL_HttpDefaultClient *)session;

Please remove the two lines above. Since the client variable isn't used, we should just delete it.

Also, NSS is compiled in C89 mode, not C99+ mode. So, we must always declare variables at the start of a block. This code will not compile with Microsoft Visual Studio.
Attachment #8347619 - Flags: review?(brian) → review-
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → nobody
Component: Security → Libraries
Product: Core → NSS
Summary: Fix warning in /security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_httpdefaultclient.c → Fix unused-but-set-variable 'client' warning in pkix_pl_httpdefaultclient.c
Version: Trunk → trunk
This is Andrei's patch with Brian's comments addressed.
Attachment #8347619 - Attachment is obsolete: true
Attachment #8581068 - Flags: review?(emaldona)
Attachment #8581068 - Flags: review?(emaldona) → review+
On behalf of Andrei: Thanks for the reviews!
Assignee: nobody → vaduva.andrei.iustin
Status: NEW → ASSIGNED
Keywords: checkin-needed
https://hg.mozilla.org/projects/nss/rev/60c35f8c4e0f
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Keywords: checkin-needed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: