-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Comments on the reply inline, followed by new review comments at the end.
On 08/07/2009 06:25 PM, Dmitri Pal wrote:
> Nack.
>
> Please squash the patch "ELAPI Adding Core Functionality" into this
> second patch. Neither one makes sense without the other.
>
Done
> I don't like the --with-config-file and --with-config-dir configure
> parameters. It's usually preferred to keep the filename constant (unless
> overridden at runtime by a user) and just specify its location.
>
> I'd suggest using the following:
> --with-config-dir [SYSCONFDIR/elapi]
> --with-extra-config-dir [SYSCONFDIR/elapi/apps.d]
>
Done
> You can't pass APP_NAME_SIZE as a string and then compare
> strlen(appname) to it. You're comparing it to the pointer address of the
> static string. You need to convert it to an integer either in the
> configure script or in the C code before you can use it that way.
>
This is not true. In the make file the defined value is not in quotes:
... -DELAPI_DEFAULT_APP_NAME=\"default\"
-DELAPI_DEFAULT_APP_NAME_SIZE=127 ...
The strings are in quotes so they are defined as strings but if you do
not specify quotes you get number.
So the ELAPI_DEFAULT_APP_NAME_SIZE is a number and the comparison works
correctly.
I also added trace and printed it as number and got expected result:
[DEBUG] elapi_log.c ( 146) ELAPI_DEFAULT_APP_NAME_SIZE = 127
This is not an issue.
You're correct. I misread the source here.
> --with-error-file doesn't make sense. There's no reason
they should need
> to change the name of the file. Possibly its location (if they want it
> somewhere other then CWD)
I do not see the reason why it should be somewhere else other than CWD.
It seemed reasonable to be to have it defined.
But it its a standard to hard code such things so be it.
I removed the option from configure and makefile and #defined name in
the source.
Brrr...
IMO from better to worse...
Dmitri, what I mean is that it's standard for the name of the file to be
hardcoded and its location to be changeable by configure.
> Your ELAPI async interface is incomplete and belongs in a
separate patch
> in any case. I will review this in more detail separately.
I can't remove it from the patch. I tried.
It is used in the core code inside the elapi_create_dispatcher_adv()
function.
This is the minimal first pass at this function.
It will be enhanced more going forward but it is sufficient for now.
The elapy_async.h has munimal set of typedefs for callbacks - nothing else.
It is still included.
Fine.
> elapi_event.c:
> add_host_identity()
> Please don't use memset on large static character arrays. It's a
> wasteful operation (in this case, it's 1025 memory writes where one is
> sufficient). It's much better to set hostname[0] = 0; and then just
> ensure null termination later if you copy data into it. Memsetting a
> character array leads to the bad assumption that you are guaranteed a
> termination. For example, when you use gethostname() later, if the
> hostname is longer than NI_MAXHOST for some reason, you are not
> guaranteed null termination. So you should manually insert a null
> terminator at hostname[NI_MAXHOST]. You do the same thing in several
> other places in this function, and throughout your code. getnameinfo()
> guarantees null termination, so memset is completely wasted here.
Well if you claim we can trust it (which I did not) then I will remove
memset.
I usually do not trust functions to claim that they return NULL
terminated strings
If you aren't sure you trust it, you can always insert a '\0' at the end
of the allocated space in order to ensure termination. You have to pass
the size of the buffer to getnameinfo() so you know it will never exceed
the length of the buffer.
until I get the proof for it. getnameinfo() is relatively new
function
at least for me.
I am used to old interface gethostname, gethostbyaddr etc. Those were
not trusted.
But things change...
Ok, done.
> getifaddrs() is not portable. It is implemented only for systems
> corresponding to BSDi, and even on those systems, it varies widely. If
> you intend to use this, it needs to be controlled by a configure flag.
>
But this is what I was told to use to get reliable address data.
I will open a ticket to make it portable.
It grants a separate effort.
Opened ticket:
https://fedorahosted.org/sssd/ticket/94
This function is supported by Ubuntu
http://manpages.ubuntu.com/manpages/karmic/man3/getifaddrs.3.html
so we are safe to have it as is for now until the ticket is addressed
later this month.
That's a reasonable plan.
> Please prefer comparisons to EOK or EXIT_SUCCESS instead of 0.
> Comparison to 0 can imply "false".
Okey. EOK then.
> Similarly,
> if (!gethostname(hostname, NI_MAXHOST)) hnm = hostname;
> doesn't read well.
>
Fixed.
> Comparing against LOCALHOSTDOMAIN is unnecessary, because it will
> already have matched LOCALHOST (since you are limiting the search to the
> length of LOCALHOST). I'd rather see you actually perform a strcasecmp
> rather than a strncasecmp here, because it's theoretically possible that
> someone could choose
localhost1.example.com for some ridiculous reason,
> and we'd be throwing it away. It's safe to omit the search limit because
> strcasecmp() will stop at the end of the shorter string.
>
Changed to strcasecmp() though I do not like it.
Thank you.
> Why are you doing a string compare of the printable versions of the
> address vs. LOCALADDRESS[V6]? It would be much faster to do a numeric
> compare of sockaddr_in->in_addr->s_addr;
>
Yes it would but there are some reasons to do it as strings.
For example there are odd cases when "127:0:0:1" is returned as name.
To catch these cases it is better to convert names and addressed to strings.
In this case you can compare them easily and do not think about IPv4 vs.
IPv6.
I know that it is a bit of cost but this is a template operation.
It is expected that templates are created infrequently, probably once
per lifetime of the application.
We discussed this with Steven and agreed that this is acceptable as is.
Yes, it occurs once per ELAPI initialization, so the performance hit is
minimal. It is worth it for the greater granularity.
> Similarly, why are we storing the host address as a string
instead of as
> an integer? Seems like a waste of space.
>
Yes but see above. You need to catch cases when name and address return
same thing. This is the indication of the odd case. You do not want to
have all events have duplicate hostname and address - it is a much
bigger waste of space and cycles.
> add_base_elements():
> pass_base = base; is an implicit signed/unsigned conversion on some
> platforms. It would be best if you defined them both as uint32_t.
>
Made it unsigned. Do not see a reason to change it to uint32_t.
That's fine for now. In the future, please prefer explicit types to
avoid potential cross-platform issues.
> interprete_key():
> For the sake of the sanity of anyone using the code, please spell
> "interpret" correctly.
Done
> There's no need to return the length of the
> strings in the function, since you know they're null-terminated.
> Returning the length is only useful in arrays without null-termination.
>
This is wrong, the whole point of returning length is that it is NOT
null terminated and
we can't alter the buffer we are reading from.
This is why we create a copy later on.
So it is essential to return the length in such cases as you underlined
above.
Thank you for clarifying. I misread here.
> convert_bool():
> I'd prefer that you use strcasecmp rather than strncasecmp unless you
> want to allow "Truest" and "Falsely" to match TRUE and FALSE as
well.
>
Ohhh... Ok, done
> process_arg_list():
> strndup() is a GNU extension, it is not portable. Since you control
> interpret_key(), you know that property will never be unreasonably large
> and will always be null-terminated, so it's safe to use strdup() here.
It is not null terminated. The whole reason of creating a copy is
because we need to NULL terminate it
but we cant alter the source string.
I changed strndup to malloc + memcpy + NULL terminate.
As mentioned above, I misread this code. The strndup was *probably*
safe, but using malloc+memcpy avoids the potential risk of other
reviewers of this code perceiving it as a safe string (as I did).
> Use the aforementioned ELAPI_KEY_TYPE_* defines here instead of
just
> if/else.
Do not understand the comment, seems incomplete.
Yeah, sorry. I had a two-part comment here that I realized was
incorrect, but only deleted the earlier part from the email. Please
disregard this.
>
> Prefer "elapi_create_event_va" to "with_args". Both
elapi_create_event()
> and elapi_create_event_with_args() take arguments.
>
>
Renamed all to be elapi_XXX_with_vargs()
> elapi_internal.c:
> This is a matter of personal preference, but I prefer
> _elapi_sink_handler() over elapi_int_sink_handler() to denote an
> internal function. I am aware that we have an _int suffix in some places
> in the code, but I'd like to recommend that we move to the underscore
> prefix. I will send out a coding style change request separately.
>
I never liked the _ as a prefix so to avoid the confusion I expanded all
_int_ suffixes to _internal_ to avoid confusion.
Perfectly acceptable to me.
> elapi_log.c:
> No issues beyond those mentioned above.
>
Run the the whole thing in valgrind, found couple issues and addressed them.
This code fails to build successfully.
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../../common/elapi
- -I../../../common/elapi/.. -I../../../common/elapi/../ini
- -I../../../common/elapi/../trace -I../../../common/elapi/../collection
- -DELAPI_DEFAULT_CONFIG_DIR=\"/etc/elapi\"
- -DELAPI_DEFAULT_CONFIG_APP_DIR=\"/etc/elapi/apps.d\"
- -DELAPI_DEFAULT_APP_NAME=\"default\" -DELAPI_DEFAULT_APP_NAME_SIZE=127
- -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual
- -Wcast-align -Wwrite-strings -g -O2 -MT elapi_event.lo -MD -MP -MF
.deps/elapi_event.Tpo -c ../../../common/elapi/elapi_event.c -o
elapi_event.o >/dev/null 2>&1
../../../common/elapi/elapi_internal.c:26:28: error: elapi_internal.h:
No such file or directory
../../../common/elapi/elapi_log.c:32:28: error: elapi_internal.h: No
such file or directory
make[4]: *** [elapi_internal.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
mv -f .deps/elapi_event.Tpo .deps/elapi_event.Plo
make[4]: *** [elapi_log.lo] Error 1
make[4]: Leaving directory `/home/sgallagh/workspace/sssd/x64/common/elapi'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/sgallagh/workspace/sssd/x64/common/elapi'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/sgallagh/workspace/sssd/x64/common'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/sgallagh/workspace/sssd/x64/common'
make: *** [all-recursive] Error 1
It would appear that you forgot to include elapi_internal.h.
Thanks for review!
New patches are attached.
>> ------------------------------------------------------------------------
>> _______________________________________________
>> Freeipa-devel mailing list
>> Freeipa-devel(a)redhat.com
>>
https://www.redhat.com/mailman/listinfo/freeipa-devel
>
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel(a)redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel
- --
Stephen Gallagher
RHCE 804006346421761
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora -
http://enigmail.mozdev.org/
iEYEARECAAYFAkqAX/8ACgkQeiVVYja6o6OE4gCgiPZdBHvQQZugeaWHv84SlIZx
XXEAnRNc2+qKnJbJ0iBvEuLCWLSLS5sf
=1zaw
-----END PGP SIGNATURE-----