From owner-p4-projects@FreeBSD.ORG Fri May 23 18:40:58 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 93438106566B; Fri, 23 May 2008 18:40:58 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 553E01065687 for ; Fri, 23 May 2008 18:40:58 +0000 (UTC) (envelope-from snagg@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id F38A08FC0C for ; Fri, 23 May 2008 18:40:57 +0000 (UTC) (envelope-from snagg@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m4NIevSl022955 for ; Fri, 23 May 2008 18:40:57 GMT (envelope-from snagg@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m4NIevxL022953 for perforce@freebsd.org; Fri, 23 May 2008 18:40:57 GMT (envelope-from snagg@FreeBSD.org) Date: Fri, 23 May 2008 18:40:57 GMT Message-Id: <200805231840.m4NIevxL022953@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to snagg@FreeBSD.org using -f From: Vincenzo Iozzo To: Perforce Change Reviews Cc: Subject: PERFORCE change 142137 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 May 2008 18:40:58 -0000 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;