From bb5e406af36a5fea23d72f7dfced76426b32dd4c Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 10 Jun 2024 16:53:09 +0200 Subject: [PATCH] Set a default value for empty task type labels --- src/emu/task.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/emu/task.c b/src/emu/task.c index 3291941..53df5db 100644 --- a/src/emu/task.c +++ b/src/emu/task.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "task.h" @@ -258,13 +258,22 @@ task_type_create(struct task_info *info, uint32_t type_id, const char *label) return -1; } - type->gid = task_get_type_gid(label); - int n = snprintf(type->label, MAX_PCF_LABEL, "%s", label); + int n; + if (label[0] == '\0') { + /* Give a name if empty */ + n = snprintf(type->label, MAX_PCF_LABEL, + "(unlabeled task type %u)", type_id); + } else { + n = snprintf(type->label, MAX_PCF_LABEL, "%s", label); + } + if (n >= MAX_PCF_LABEL) { - err("task type label too long: %s", label); + err("task type %u label too long", type_id); return -1; } + type->gid = task_get_type_gid(type->label); + /* Add the new task type to the hash table */ HASH_ADD_INT(info->types, id, type);