* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
+ * or https://opensource.org/licenses/CDDL-1.0.
* See the License for the specific language governing permissions
* and limitations under the License.
*
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <sys/list.h>
#include <sys/time.h>
fmd_serd_eng_t *sgp;
sgp = malloc(sizeof (fmd_serd_eng_t));
- bzero(sgp, sizeof (fmd_serd_eng_t));
+ if (sgp == NULL) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
+ memset(sgp, 0, sizeof (fmd_serd_eng_t));
sgp->sg_name = strdup(name);
+ if (sgp->sg_name == NULL) {
+ perror("strdup");
+ exit(EXIT_FAILURE);
+ }
+
sgp->sg_flags = FMD_SERD_DIRTY;
sgp->sg_n = n;
sgp->sg_t = t;
shp->sh_hashlen = FMD_STR_BUCKETS;
shp->sh_hash = calloc(shp->sh_hashlen, sizeof (void *));
shp->sh_count = 0;
+
+ if (shp->sh_hash == NULL) {
+ perror("calloc");
+ exit(EXIT_FAILURE);
+ }
+
}
void
}
free(shp->sh_hash);
- bzero(shp, sizeof (fmd_serd_hash_t));
+ memset(shp, 0, sizeof (fmd_serd_hash_t));
}
void
if (sgp->sg_flags & FMD_SERD_FIRED) {
serd_log_msg(" SERD Engine: record %s already fired!",
sgp->sg_name);
- return (FMD_B_FALSE);
+ return (B_FALSE);
}
while (sgp->sg_count >= sgp->sg_n)
fmd_serd_eng_discard(sgp, list_tail(&sgp->sg_list));
sep = malloc(sizeof (fmd_serd_elem_t));
+ if (sep == NULL) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
sep->se_hrt = hrt;
list_insert_head(&sgp->sg_list, sep);
fmd_event_delta(oep->se_hrt, sep->se_hrt) <= sgp->sg_t) {
sgp->sg_flags |= FMD_SERD_FIRED | FMD_SERD_DIRTY;
serd_log_msg(" SERD Engine: fired %s", sgp->sg_name);
- return (FMD_B_TRUE);
+ return (B_TRUE);
}
sgp->sg_flags |= FMD_SERD_DIRTY;
- return (FMD_B_FALSE);
+ return (B_FALSE);
}
int
void
fmd_serd_eng_reset(fmd_serd_eng_t *sgp)
{
- serd_log_msg(" SERD Engine: reseting %s", sgp->sg_name);
+ serd_log_msg(" SERD Engine: resetting %s", sgp->sg_name);
while (sgp->sg_count != 0)
fmd_serd_eng_discard(sgp, list_head(&sgp->sg_list));
}
void
-fmd_serd_eng_gc(fmd_serd_eng_t *sgp)
+fmd_serd_eng_gc(fmd_serd_eng_t *sgp, void *arg)
{
+ (void) arg;
fmd_serd_elem_t *sep, *nep;
hrtime_t hrt;
return; /* no garbage collection needed if empty or fired */
sep = list_head(&sgp->sg_list);
+ if (sep == NULL)
+ return;
+
hrt = sep->se_hrt - sgp->sg_t;
for (sep = list_head(&sgp->sg_list); sep != NULL; sep = nep) {