Re: [Nagios-devel] [PATCH 3/5] base/workers: Fix detection of check

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] [PATCH 3/5] base/workers: Fix detection of check

Post by Guest »

On 11/05/2012 02:58 PM, [email protected] wrote:
> From: Robin Sonefors
>
> strrchr may search from the end of the string, but it still expects the
> pointer it is provided to point to the beginning of the string. Thus, we'd
> only check if the last byte was a slash, rather than for the last slash.
>
> Manipulating the cmd_name for basename discovery is unnecessary, so
> don't.
>
> Signed-off-by: Robin Sonefors
> ---
> base/workers.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/base/workers.c b/base/workers.c
> index 0f33a8a..7042724 100644
> --- a/base/workers.c
> +++ b/base/workers.c
> @@ -807,14 +807,12 @@ static worker_process *get_worker(worker_job *job)
> cmd_name = job->command;
> if ((space = strchr(cmd_name, ' ')) != NULL) {
> *space = '\0';
> - slash = strrchr(space - 1, '/');
> + slash = strrchr(cmd_name, '/');

Actually, nvm about the comment thing. *space = '\0' means strrchr()
works. I was thinking memrchr() was needed, but it isn't. Nice work.

--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked