Cleanup: remove redundant calls to strlen

This commit is contained in:
Campbell Barton
2025-07-26 12:08:15 +00:00
parent 0531230a35
commit faed51f195
6 changed files with 7 additions and 7 deletions

View File

@@ -264,7 +264,7 @@ char *BKE_cryptomatte_entries_to_matte_id(NodeCryptomatte *node_storage)
if (!first) {
BLI_dynstr_append(matte_id, ",");
}
if (STRNLEN(entry->name) != 0) {
if (entry->name[0] != '\0') {
BLI_dynstr_nappend(matte_id, entry->name, sizeof(entry->name));
}
else {

View File

@@ -317,8 +317,8 @@ size_t BLI_string_flip_side_name(char *name_dst,
if (strip_number == false) {
BLI_strncpy(number, index, name_dst_maxncpy);
}
*index = 0;
len = BLI_strnlen(name_dst, name_dst_maxncpy);
*index = '\0';
len = size_t(index - name_dst); /* Same as `strlen(name_dst)`. */
}
}

View File

@@ -1549,7 +1549,7 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain)
if (node->type_legacy == CMP_NODE_CRYPTOMATTE_LEGACY) {
NodeCryptomatte *storage = (NodeCryptomatte *)node->storage;
char *matte_id = storage->matte_id;
if (matte_id == nullptr || strlen(storage->matte_id) == 0) {
if ((matte_id == nullptr) || (storage->matte_id[0] == '\0')) {
continue;
}
BKE_cryptomatte_matte_id_to_entries(storage, storage->matte_id);

View File

@@ -144,7 +144,7 @@ static void fill_locales()
if (id == 0) {
/* The DEFAULT/Automatic item... */
if (BLI_strnlen(loc, 2)) {
if (loc[0] != '\0') {
MEM_freeN(desc); /* Not used here. */
locales[id] = "";
/* Keep this tip in sync with the one in rna_userdef

View File

@@ -453,7 +453,7 @@ static void workspace_append_button(uiLayout *layout,
const ID *id = (ID *)workspace;
const char *filepath = from_main->filepath;
if (strlen(filepath) == 0) {
if (filepath[0] == '\0') {
filepath = BLO_EMBEDDED_STARTUP_BLEND;
}

View File

@@ -2131,7 +2131,7 @@ static wmOperatorStatus node_output_file_add_socket_exec(bContext *C, wmOperator
RNA_string_get(op->ptr, "file_path", file_path);
if (strlen(file_path) != 0) {
if (file_path[0] != '\0') {
ntreeCompositOutputFileAddSocket(ntree, node, file_path, &scene->r.im_format);
}
else {