pkarashchenko commented on code in PR #7900: URL: https://github.com/apache/nuttx/pull/7900#discussion_r1050651277
########## drivers/note/noteram_driver.c: ########## @@ -820,7 +638,7 @@ void sched_note_add(FAR const void *note, size_t notelen) note_st = (FAR struct note_start_s *)note; if (note_st->nst_cmn.nc_type == NOTE_START) { - noteram_record_taskname(note_st->nst_cmn.nc_pid[0] + + note_record_taskname(note_st->nst_cmn.nc_pid[0] + (note_st->nst_cmn.nc_pid[1] << 8), note_st->nst_name); Review Comment: ```suggestion note_record_taskname(note_st->nst_cmn.nc_pid[0] + (note_st->nst_cmn.nc_pid[1] << 8), note_st->nst_name); ``` ########## include/nuttx/note/note_driver.h: ########## @@ -62,4 +62,74 @@ int note_initialize(void); #endif /* defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT) */ +#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 + +/**************************************************************************** + * Name: note_get_taskname + * + * Description: + * Get the task name string of the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name string + * If the corresponding name doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +const char *note_get_taskname(pid_t pid); + +/**************************************************************************** + * Name: note_record_taskname + * + * Description: + * Record the task name info of the specified task + * + * Input Parameters: + * PID - Task ID + * name - task name + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_record_taskname(pid_t pid, const char *name); Review Comment: ```suggestion void note_record_taskname(pid_t pid, FAR const char *name); ``` ########## drivers/note/note_taskname.c: ########## @@ -0,0 +1,242 @@ +/**************************************************************************** + * drivers/note/note_taskname.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stddef.h> +#include <string.h> +#include <assert.h> + +#include <nuttx/irq.h> +#include <nuttx/sched.h> + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined (CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) && \ + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +struct note_taskname_info_s +{ + uint8_t size; + uint8_t pid[2]; + char name[1]; +}; + +struct note_taskname_s +{ + int buffer_used; + char buffer[CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +static struct note_taskname_s g_note_taskname; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_find_taskname + * + * Description: + * Find task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name info + * If the corresponding info doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +static FAR struct note_taskname_info_s *note_find_taskname(pid_t pid) +{ + int n; + FAR struct note_taskname_info_s *ti; + + for (n = 0; n < g_note_taskname.buffer_used; ) + { + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[n]; + if (ti->pid[0] + (ti->pid[1] << 8) == pid) + { + return ti; + } + + n += ti->size; + } + + return NULL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_record_taskname + * + * Description: + * Record the task name info of the specified task + * + * Input Parameters: + * PID - Task ID + * name - task name + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_record_taskname(pid_t pid, const char *name) Review Comment: ```suggestion void note_record_taskname(pid_t pid, FAR const char *name) ``` ########## drivers/note/note_taskname.c: ########## @@ -0,0 +1,242 @@ +/**************************************************************************** + * drivers/note/note_taskname.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stddef.h> +#include <string.h> +#include <assert.h> + +#include <nuttx/irq.h> +#include <nuttx/sched.h> + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined (CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) && \ Review Comment: ```suggestion #if defined(CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) && \ ``` ########## include/nuttx/note/note_driver.h: ########## @@ -62,4 +62,74 @@ int note_initialize(void); #endif /* defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT) */ +#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 + +/**************************************************************************** + * Name: note_get_taskname + * + * Description: + * Get the task name string of the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name string + * If the corresponding name doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +const char *note_get_taskname(pid_t pid); Review Comment: ```suggestion FAR const char *note_get_taskname(pid_t pid); ``` ########## drivers/note/note_taskname.c: ########## @@ -0,0 +1,242 @@ +/**************************************************************************** + * drivers/note/note_taskname.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stddef.h> +#include <string.h> +#include <assert.h> + +#include <nuttx/irq.h> +#include <nuttx/sched.h> + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined (CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) && \ + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +struct note_taskname_info_s +{ + uint8_t size; + uint8_t pid[2]; + char name[1]; +}; + +struct note_taskname_s +{ + int buffer_used; + char buffer[CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +static struct note_taskname_s g_note_taskname; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_find_taskname + * + * Description: + * Find task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name info + * If the corresponding info doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +static FAR struct note_taskname_info_s *note_find_taskname(pid_t pid) +{ + int n; + FAR struct note_taskname_info_s *ti; + + for (n = 0; n < g_note_taskname.buffer_used; ) + { + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[n]; + if (ti->pid[0] + (ti->pid[1] << 8) == pid) + { + return ti; + } + + n += ti->size; + } + + return NULL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_record_taskname + * + * Description: + * Record the task name info of the specified task + * + * Input Parameters: + * PID - Task ID + * name - task name + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_record_taskname(pid_t pid, const char *name) +{ + FAR struct note_taskname_info_s *ti; + size_t tilen; + size_t namelen; + + namelen = strlen(name); + DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE); + tilen = sizeof(struct note_taskname_info_s) + namelen; + DEBUGASSERT(tilen <= UCHAR_MAX); + + if (g_note_taskname.buffer_used + tilen > + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) + { + /* No space in the buffer - ignored */ + + return; + } + + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[g_note_taskname.buffer_used]; + ti->size = tilen; + ti->pid[0] = pid & 0xff; + ti->pid[1] = (pid >> 8) & 0xff; + strlcpy(ti->name, name, namelen + 1); + g_note_taskname.buffer_used += tilen; +} + +/**************************************************************************** + * Name: note_remove_taskname + * + * Description: + * Remove the task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_remove_taskname(pid_t pid) +{ + FAR struct note_taskname_info_s *ti; + size_t tilen; + char *src; + int sindex; + + ti = note_find_taskname(pid); + if (ti == NULL) + { + return; + } + + tilen = ti->size; + src = (char *)ti + tilen; Review Comment: ```suggestion src = (FAR char *)ti + tilen; ``` ########## drivers/note/noteram_driver.c: ########## @@ -745,7 +563,7 @@ static int noteram_ioctl(struct file *filep, int cmd, unsigned long arg) } param = (struct noteram_get_taskname_s *)arg; Review Comment: ```suggestion param = (FAR struct noteram_get_taskname_s *)arg; ``` ########## drivers/note/note_taskname.c: ########## @@ -0,0 +1,242 @@ +/**************************************************************************** + * drivers/note/note_taskname.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stddef.h> +#include <string.h> +#include <assert.h> + +#include <nuttx/irq.h> +#include <nuttx/sched.h> + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined (CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) && \ + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +struct note_taskname_info_s +{ + uint8_t size; + uint8_t pid[2]; + char name[1]; +}; + +struct note_taskname_s +{ + int buffer_used; + char buffer[CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +static struct note_taskname_s g_note_taskname; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_find_taskname + * + * Description: + * Find task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name info + * If the corresponding info doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +static FAR struct note_taskname_info_s *note_find_taskname(pid_t pid) +{ + int n; + FAR struct note_taskname_info_s *ti; + + for (n = 0; n < g_note_taskname.buffer_used; ) + { + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[n]; + if (ti->pid[0] + (ti->pid[1] << 8) == pid) + { + return ti; + } + + n += ti->size; + } + + return NULL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_record_taskname + * + * Description: + * Record the task name info of the specified task + * + * Input Parameters: + * PID - Task ID + * name - task name + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_record_taskname(pid_t pid, const char *name) +{ + FAR struct note_taskname_info_s *ti; + size_t tilen; + size_t namelen; + + namelen = strlen(name); + DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE); + tilen = sizeof(struct note_taskname_info_s) + namelen; + DEBUGASSERT(tilen <= UCHAR_MAX); + + if (g_note_taskname.buffer_used + tilen > + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) + { + /* No space in the buffer - ignored */ + + return; + } + + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[g_note_taskname.buffer_used]; + ti->size = tilen; + ti->pid[0] = pid & 0xff; + ti->pid[1] = (pid >> 8) & 0xff; + strlcpy(ti->name, name, namelen + 1); + g_note_taskname.buffer_used += tilen; +} + +/**************************************************************************** + * Name: note_remove_taskname + * + * Description: + * Remove the task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_remove_taskname(pid_t pid) +{ + FAR struct note_taskname_info_s *ti; + size_t tilen; + char *src; + int sindex; + + ti = note_find_taskname(pid); + if (ti == NULL) + { + return; + } + + tilen = ti->size; + src = (char *)ti + tilen; + sindex = src - g_note_taskname.buffer; + + memcpy(ti, src, g_note_taskname.buffer_used - sindex); + g_note_taskname.buffer_used -= tilen; +} + +/**************************************************************************** + * Name: note_get_taskname + * + * Description: + * Get the task name string of the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name string + * If the corresponding name doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +const char *note_get_taskname(pid_t pid) Review Comment: ```suggestion FAR const char *note_get_taskname(pid_t pid) ``` ########## drivers/note/note_taskname.c: ########## @@ -0,0 +1,242 @@ +/**************************************************************************** + * drivers/note/note_taskname.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stddef.h> +#include <string.h> +#include <assert.h> + +#include <nuttx/irq.h> +#include <nuttx/sched.h> + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined (CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) && \ + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +struct note_taskname_info_s +{ + uint8_t size; + uint8_t pid[2]; + char name[1]; +}; + +struct note_taskname_s +{ + int buffer_used; + char buffer[CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +static struct note_taskname_s g_note_taskname; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_find_taskname + * + * Description: + * Find task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name info + * If the corresponding info doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +static FAR struct note_taskname_info_s *note_find_taskname(pid_t pid) +{ + int n; + FAR struct note_taskname_info_s *ti; + + for (n = 0; n < g_note_taskname.buffer_used; ) + { + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[n]; + if (ti->pid[0] + (ti->pid[1] << 8) == pid) + { + return ti; + } + + n += ti->size; + } + + return NULL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_record_taskname + * + * Description: + * Record the task name info of the specified task + * + * Input Parameters: + * PID - Task ID + * name - task name + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_record_taskname(pid_t pid, const char *name) +{ + FAR struct note_taskname_info_s *ti; + size_t tilen; + size_t namelen; + + namelen = strlen(name); + DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE); + tilen = sizeof(struct note_taskname_info_s) + namelen; + DEBUGASSERT(tilen <= UCHAR_MAX); + + if (g_note_taskname.buffer_used + tilen > + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) + { + /* No space in the buffer - ignored */ + + return; + } + + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[g_note_taskname.buffer_used]; + ti->size = tilen; + ti->pid[0] = pid & 0xff; + ti->pid[1] = (pid >> 8) & 0xff; + strlcpy(ti->name, name, namelen + 1); + g_note_taskname.buffer_used += tilen; +} + +/**************************************************************************** + * Name: note_remove_taskname + * + * Description: + * Remove the task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_remove_taskname(pid_t pid) +{ + FAR struct note_taskname_info_s *ti; + size_t tilen; + char *src; + int sindex; + + ti = note_find_taskname(pid); + if (ti == NULL) + { + return; + } + + tilen = ti->size; + src = (char *)ti + tilen; + sindex = src - g_note_taskname.buffer; + + memcpy(ti, src, g_note_taskname.buffer_used - sindex); + g_note_taskname.buffer_used -= tilen; +} + +/**************************************************************************** + * Name: note_get_taskname + * + * Description: + * Get the task name string of the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name string + * If the corresponding name doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +const char *note_get_taskname(pid_t pid) +{ + irqstate_t irq_mask; + const char *ret = NULL; Review Comment: ```suggestion FAR const char *ret = NULL; ``` ########## drivers/note/note_taskname.c: ########## @@ -0,0 +1,242 @@ +/**************************************************************************** + * drivers/note/note_taskname.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stddef.h> +#include <string.h> +#include <assert.h> + +#include <nuttx/irq.h> +#include <nuttx/sched.h> + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined (CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) && \ + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +struct note_taskname_info_s +{ + uint8_t size; + uint8_t pid[2]; + char name[1]; +}; + +struct note_taskname_s +{ + int buffer_used; + char buffer[CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0 +static struct note_taskname_s g_note_taskname; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_find_taskname + * + * Description: + * Find task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * Pointer to the task name info + * If the corresponding info doesn't exist in the buffer, NULL is returned. + * + ****************************************************************************/ + +static FAR struct note_taskname_info_s *note_find_taskname(pid_t pid) +{ + int n; + FAR struct note_taskname_info_s *ti; + + for (n = 0; n < g_note_taskname.buffer_used; ) + { + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[n]; + if (ti->pid[0] + (ti->pid[1] << 8) == pid) + { + return ti; + } + + n += ti->size; + } + + return NULL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: note_record_taskname + * + * Description: + * Record the task name info of the specified task + * + * Input Parameters: + * PID - Task ID + * name - task name + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_record_taskname(pid_t pid, const char *name) +{ + FAR struct note_taskname_info_s *ti; + size_t tilen; + size_t namelen; + + namelen = strlen(name); + DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE); + tilen = sizeof(struct note_taskname_info_s) + namelen; + DEBUGASSERT(tilen <= UCHAR_MAX); + + if (g_note_taskname.buffer_used + tilen > + CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE) + { + /* No space in the buffer - ignored */ + + return; + } + + ti = (FAR struct note_taskname_info_s *) + &g_note_taskname.buffer[g_note_taskname.buffer_used]; + ti->size = tilen; + ti->pid[0] = pid & 0xff; + ti->pid[1] = (pid >> 8) & 0xff; + strlcpy(ti->name, name, namelen + 1); + g_note_taskname.buffer_used += tilen; +} + +/**************************************************************************** + * Name: note_remove_taskname + * + * Description: + * Remove the task name info corresponding to the specified PID + * + * Input Parameters: + * PID - Task ID + * + * Returned Value: + * None + * + ****************************************************************************/ + +void note_remove_taskname(pid_t pid) +{ + FAR struct note_taskname_info_s *ti; + size_t tilen; + char *src; Review Comment: ```suggestion FAR char *src; ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org