[LU-4189] Strange code in mdc_changelog_send_thread Created: 30/Oct/13  Updated: 07/Jul/15  Resolved: 07/Jul/15

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.6.0
Fix Version/s: Lustre 2.8.0

Type: Bug Priority: Minor
Reporter: Oleg Drokin Assignee: WC Triage
Resolution: Fixed Votes: 0
Labels: easy, patch

Issue Links:
Related
is related to LU-2753 Tracking bug for static code analysis... Resolved
Severity: 3
Rank (Obsolete): 11329

 Description   

Playing with the stack tool, it uncovered this strange piece in mdc_changelog_send_thread:

        /* Send EOF no matter what our result */
        if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch),
                                      cs->cs_flags))) {
                kuch->kuc_msgtype = CL_EOF;
                libcfs_kkuc_msg_put(cs->cs_fp, kuch);
        }

Now, the thing is that changelog_kuc_hdr never returns NULL as we pass the pointer into it already and if it's zero, we'd totally die before even returning:

static struct kuc_hdr *changelog_kuc_hdr(char *buf, int len, int flags)
{
        struct kuc_hdr *lh = (struct kuc_hdr *)buf;

        LASSERT(len <= KUC_CHANGELOG_MSG_MAXSIZE);

        lh->kuc_magic = KUC_MAGIC;
        lh->kuc_transport = KUC_TRANSPORT_CHANGELOG;
        lh->kuc_flags = flags;
        lh->kuc_msgtype = CL_RECORD;
        lh->kuc_msglen = len;
        return lh;
}

So I guess weeither should do away with the if here and make for a more readable code, or actually insert some checks into changelog_kuc_hdr



 Comments   
Comment by Gerrit Updater [ 03/Dec/14 ]

Henri Doreau (henri.doreau@cea.fr) uploaded a new patch: http://review.whamcloud.com/12919
Subject: LU-4189 mdc: Removed unneeded NULL check
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: ff9653d1ab1c9921520205a43b2797cfdf11fe2a

Comment by Henri Doreau (Inactive) [ 22/Jan/15 ]

I have posted a patch to clean that on http://review.whamcloud.com/#/c/12919/

Could someone have a look? I'm not sure who to add as reviewer.

Comment by Gerrit Updater [ 28/Apr/15 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch http://review.whamcloud.com/12919/
Subject: LU-4189 mdc: Removed unneeded NULL check
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 83fedb85505f2da7d34f7140e170ba52759e705b

Comment by Peter Jones [ 07/Jul/15 ]

landed for 2.8

Generated at Sat Feb 10 01:40:28 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.