[PATCH phosphor-event v3] Add association interface to each event log
Joel Stanley
joel at jms.id.au
Thu Mar 10 14:09:43 AEDT 2016
On Tue, Mar 8, 2016 at 7:00 AM, OpenBMC Patches
<openbmc-patches at stwcx.xyz> wrote:
>
> +static int prop_message_assoc(sd_bus *bus,
> + const char *path,
> + const char *interface,
> + const char *property,
> + sd_bus_message *reply,
> + void *userdata,
> + sd_bus_error *error)
> +{
> + int r=0;
> + messageEntry_t *m = (messageEntry_t*) userdata;
This is c, you don't need to cast a void * to your type.
> + event_record_t *rec;
> + char *p;
> + char *token;
> +
> + rec = message_record_open(m->em, m->logid);
> + if (!rec) {
> + fprintf(stderr,"Warning missing evnet log for %lx\n", m->logid);
> + sd_bus_error_set(error,
> + SD_BUS_ERROR_FILE_NOT_FOUND,
> + "Could not find log file");
> + return -1;
> + }
> +
> + p = rec->association;
> +
> + token = strtok(p, " ");
> + if (token) {
> + r = sd_bus_message_open_container(reply, 'a', "(sss)");
> + if (r < 0) {
> + fprintf(stderr,"Error opening container %s to reply %s\n", token, strerror(-r));
Do you need to exit here if the reply could not be opened?
> + }
> +
> + while(token) {
> +
> + r = sd_bus_message_append(reply, "(sss)", "fru", "event", token);
> + if (r < 0) {
> + fprintf(stderr,"Error adding properties for %s to reply %s\n", token, strerror(-r));
> + }
> +
> + token = strtok(NULL, " ");
> + }
> +
> + r = sd_bus_message_close_container(reply);
> + }
Do you need to close the thing you opened with message_record_open?
> +
> + return r;
> +}
>
>
More information about the openbmc
mailing list