[PATCH]Remove the redundant assignment

From: "Feilong Meng" <feelingmeng(at)foxmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: [PATCH]Remove the redundant assignment
Date: 2025-12-16 06:18:05
Message-ID: tencent_771178777C5BC17FCB7F7A1771CD1FFD5708@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,Hackers,

I found that in the InjectionPointAttach function within the src/backend/utils/misc/injection_point.c file, the variable is manually assigned a '\0' at the end, even though strlcpy already guarantees that the destination buffer will be null-terminated and will not overflow.

The code modification is as follows:

```
/* Save the entry */
strlcpy(entry->name, name, sizeof(entry->name));
entry->name[INJ_NAME_MAXLEN - 1] = '\0'; <== Delete this line
strlcpy(entry->library, library, sizeof(entry->library));
entry->library[INJ_LIB_MAXLEN - 1] = '\0'; <== Delete this line
strlcpy(entry->function, function, sizeof(entry->function));
entry->function[INJ_FUNC_MAXLEN - 1] = '\0'; <== Delete this line
```

And in the injection_point_cache_add function within the same file, strlcpy(entry->name, name, sizeof(entry->name)); does not perform redundant assignment.

I have tested the change, and "make check" passed.

--------------

Best regards,

Feilong Meng

Attachment Content-Type Size
0001-Remove-the-redundant-assignment-in-InjectionPointAtt.patch application/octet-stream 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-12-16 06:32:20 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Michael Paquier 2025-12-16 06:04:56 Re: Fix crash during recovery when redo segment is missing