Changeset f72ae3b in mainline


Ignore:
Timestamp:
2012-08-16T23:36:59Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f039dba
Parents:
330a59f
Message:

log_create returns parent in case of errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/log.c

    r330a59f rf72ae3b  
    195195}
    196196
    197 /** Create logging context.
    198  *
    199  * This function always returns a valid context.
     197/** Create a new (sub-) log.
     198 *
     199 * This function always returns a valid log_t. In case of errors,
     200 * @c parent is returned and errors are silently ignored.
     201 *
     202 * @param name Log name under which message will be reported (appended to parents name).
     203 * @param parent Parent log.
     204 * @return Opaque identifier of the newly created log.
    200205 */
    201206log_t log_create(const char *name, log_t parent)
     
    204209        if (info == NULL)
    205210                return LOG_DEFAULT;
     211        info->name = NULL;
    206212
    207213        if (parent == LOG_DEFAULT) {
    208214                info->name = str_dup(name);
    209                 if (info->name == NULL) {
    210                         free(info);
    211                         return LOG_DEFAULT;
    212                 }
     215                if (info->name == NULL)
     216                        goto error;
    213217                info->top_log_id = default_top_log_id;
    214218        } else {
     
    216220                int rc = asprintf(&info->name, "%s/%s",
    217221                    parent_info->name, name);
    218                 if (rc < 0) {
    219                         free(info);
    220                         return LOG_DEFAULT;
    221                 }
     222                if (rc < 0)
     223                        goto error;
    222224                info->top_log_id = parent_info->top_log_id;
    223225        }
     
    245247        free(info->name);
    246248        free(info);
    247         return LOG_DEFAULT;
     249        return parent;
    248250}
    249251
Note: See TracChangeset for help on using the changeset viewer.