[OPEN-ILS-DEV] PATCH: oils_auth.c (misc. cleanup)

Scott McKellar mck9 at swbell.net
Sun Nov 25 18:15:21 EST 2007


This patch includes miscellaneous cleanups.  Summary:

1. Apply the const qualifier where possible.

2. Plug memory leaks.

3. Make some global things static.

4. Some minor tidying-up.

Details:

1. The variables __oilsAuthOPACTimeout, __oilsAuthStaffTimeout and
and __oilsAuthOverrideTimeout are now static, since no other file
references them.  Also I reduced the leading underscores to one each.

2. In several places I replaced jsonObjectGetKey() with
jsonObjectGetKeyConst().

3. In oilsAuthInit(): I plugged a memory leak by moving the freeing
of username out of an else block and into the code following.

4. In oilsAuthVerifyPassword(): I plugged a memory leak in the case
of an early return.

5. In oilsAuthVerifyWorkstation: I plugged a memory leak by freeing
workstation at the end.

6. In oilsAuthCheckCard(): I eliminated the ctx and userObj parameters.
The function didn't do anything with them except to verify that they
weren't NULL.  I transferred that responsibility to the calling code
in oilsAuthComplete() (where I also plugged another memory leak).

7. Also in oilsAuthCheckCard(): I plugged a memory leak by freeing
params and card.  Also I rearranged the last few lines a bit so that
we free active in only one place.

8. In oilsAuthComplete(): I plugged a number of memory leaks caused
by a failure to free userObj in various early returns.

9. Also in oilsAuthComplete(): In order to be able make uname a const
pointer, but still be able to delete it when necessary, I created an
intermdiate non-const pointer named freeable_uname -- which also takes
the place of the original freeuname variable used as a boolean.

10. In oilsAuthSessionRetrieve(): I moved the freeing of evt out of
the if-else structure and put it at the end, to make sure that none
of the branches would miss it.

11. Also in oilsAuthSessionRetrieve(): one of the branches of the
if-else had a second variable named evt, hiding the variable of the
same name declared in an enclosing scope.  That's not a bug, but it's
confusing.  I renamed it to evt2.

12. The following functions are now static:

    oilsAuthCheckLoginPerm()
    oilsAuthVerifyPassword()
    oilsAuthGetTimeout()
    oilsAuthHandleLoginOK()
    oilsAuthVerifyWorkstation()
    _oilsAuthResetTimeout()

13. I added the const qualifier to various parameters and local
variables.

Scott McKellar
http://home.swbell.net/mck9/ct/

Developer's Certificate of Origin 1.1 By making a contribution to
this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license indicated
in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source license
and I have the right under that license to submit that work with
modifications, whether created in whole or in part by me, under the
same open source license (unless I am permitted to submit under a
different license), as indicated in the file; or

(c) The contribution was provided directly to me by some other person
who certified (a), (b) or (c) and I have not modified it; and

(d) In the case of each of (a), (b), or (c), I understand and agree
that this project and the contribution are public and that a record
of the contribution (including all personal information I submit
with it, including my sign-off) is maintained indefinitely and may
be redistributed consistent with this project or the open source
license indicated in the file.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: oils_auth_c_1.patch
Type: text/x-patch
Size: 17406 bytes
Desc: 243675539-oils_auth_c_1.patch
Url : http://list.georgialibraries.org/pipermail/open-ils-dev/attachments/20071125/51ef18bd/oils_auth_c_1.bin


More information about the Open-ils-dev mailing list