Date: Fri, 23 May 2008 18:40:57 GMT From: Vincenzo Iozzo <snagg@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 142137 for review Message-ID: <200805231840.m4NIevxL022953@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=142137 Change 142137 by snagg@snagg_macosx on 2008/05/23 18:40:14 Some style fixes. the preselect_set_event was patched setting the number of event as the value decided by the user not a fixed one, so that qsort doesn't fail. Affected files ... .. //depot/projects/soc2008/snagg-audit/sys/security/audit/audit_pipe.c#16 edit Differences ... ==== //depot/projects/soc2008/snagg-audit/sys/security/audit/audit_pipe.c#16 (text) ==== @@ -233,15 +233,16 @@ static int audit_pipe_compare_preselect_event(const void *a, const void *b) { - const struct audit_pipe_preselect_event *entrya = a; - const struct audit_pipe_preselect_event *entryb = b; - + const struct audit_pipe_preselect_event *entrya, *entryb; + + entrya = a; + entryb = b; if(entrya->app_event > entryb->app_event) - return 1; + return (1); else if (entrya->app_event < entryb->app_event) - return -1; + return (-1); else - return 0; + return (0); } @@ -257,11 +258,10 @@ struct audit_pipe_preselect_event *event; struct audit_pipe_preselect_event ev_a; + mtx_assert(&audit_pipe_mtx, MA_OWNED); + ev_a.app_event = app_event; ev_a.app_flag = event_flag; - - mtx_assert(&audit_pipe_mtx, MA_OWNED); - TAILQ_FOREACH(app, &ap->ap_preselect_list, app_list) { if(app->app_pid == app_pid) { /* Just skip if we are interested only in the pid. */ @@ -356,10 +356,11 @@ * Pessimistically assume that the entry for this pid doesn't * exist, and allocate. We will free it if it is unneeded. */ + KASSERT(num >= 0, ("Number of events is out of range")); app_new = malloc(sizeof(*app_new), M_AUDIT_PIPE_PRESELECT, M_WAITOK); - app_new->app_auevents= malloc(sizeof(struct audit_pipe_preselect_event) - * AUDIT_NEVENTS, M_AUDIT_PIPE_PRESELECT_EVENT, - M_WAITOK); + app_new->app_auevents= malloc(sizeof(struct audit_pipe_preselect_event) * + num, M_AUDIT_PIPE_PRESELECT_EVENT, M_WAITOK); + mtx_lock(&audit_pipe_mtx); /* @@ -367,9 +368,10 @@ */ app = audit_pipe_preselect_find_event(ap, -1, app_pid, -1); found = (app != NULL) ? 1: 0; - if(found) { - KASSERT(num <= app->app_event_len, - ("Number of events is out of range")); + if(found) { + app->app_auevents = app_new->app_auevents; + app_new = NULL; + app->app_event_len = num; for (i = 0; i < num; i++) { (app->app_auevents + i)->app_event = (events + i)->app_event; (app->app_auevents + i)->app_flag = (events + i)->app_flag; @@ -381,7 +383,7 @@ app = app_new; app_new = NULL; app->app_pid = app_pid; - app->app_event_len = AUDIT_NEVENTS; + app->app_event_len = num; for (i = 0; i < num; i++) { (app->app_auevents + i)->app_event = (events + i)->app_event; (app->app_auevents + i)->app_flag = (events + i)->app_flag;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805231840.m4NIevxL022953>