Please squash the patch "ELAPI Adding Core Functionality" into this
second patch. Neither one makes sense without the other.
I don't like the --with-config-file and --with-config-dir
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:
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:
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
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.
--with-error-file doesn't make sense. There's no reason they
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
IMO from better to worse...
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()
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.
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; 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
I usually do not trust functions to claim that they return NULL
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
But things change...
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
so we are safe to have it as is for now until the ticket is addressed
later this month.
Please prefer comparisons to EOK or EXIT_SUCCESS instead of 0.
Comparison to 0 can imply "false".
Okey. EOK then.
if (!gethostname(hostname, NI_MAXHOST)) hnm = hostname;
doesn't read well.
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.
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.
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.
Similarly, why are we storing the host address as a string instead of
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.
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.
For the sake of the sanity of anyone using the code, please spell
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
I'd prefer that you use strcasecmp rather than strncasecmp unless you
want to allow "Truest" and "Falsely" to match TRUE and FALSE as
Ohhh... Ok, done
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.
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.
Use the aforementioned ELAPI_KEY_TYPE_* defines here instead of just
Do not understand the comment, seems incomplete.
Prefer "elapi_create_event_va" to "with_args". Both
and elapi_create_event_with_args() take arguments.
Renamed all to be elapi_XXX_with_vargs()
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.
No issues beyond those mentioned above.
Run the the whole thing in valgrind, found couple issues and addressed them.
Thanks for review!
New patches are attached.
> Freeipa-devel mailing list
Freeipa-devel mailing list
Engineering Manager IPA project,
Red Hat Inc.
Looking to carve out IT costs?