Commit b6b38f70 authored by Joe Perches's avatar Joe Perches Committed by Steve French
Browse files

[CIFS] Neaten cERROR and cFYI macros, reduce text space



Neaten cERROR and cFYI macros, reduce text space
~2.5K

Convert '__FILE__ ": " fmt' to '"%s: " fmt', __FILE__' to save text space
Surround macros with do {} while
Add parentheses to macros
Make statement expression macro from macro with assign
Remove now unnecessary parentheses from cFYI and cERROR uses

defconfig with CIFS support old
$ size fs/cifs/built-in.o
   text	   data	    bss	    dec	    hex	filename
 156012	   1760	    148	 157920	  268e0	fs/cifs/built-in.o

defconfig with CIFS support old
$ size fs/cifs/built-in.o
   text	   data	    bss	    dec	    hex	filename
 153508	   1760	    148	 155416	  25f18	fs/cifs/built-in.o

allyesconfig old:
$ size fs/cifs/built-in.o
   text	   data	    bss	    dec	    hex	filename
 309138	   3864	  74824	 387826	  5eaf2	fs/cifs/built-in.o

allyesconfig new
$ size fs/cifs/built-in.o
   text	   data	    bss	    dec	    hex	filename
 305655	   3864	  74824	 384343	  5dd57	fs/cifs/built-in.o

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 315e995c
Loading
Loading
Loading
Loading
+34 −39
Original line number Diff line number Diff line
@@ -510,11 +510,11 @@ decode_negTokenInit(unsigned char *security_blob, int length,

	/* GSSAPI header */
	if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
		cFYI(1, ("Error decoding negTokenInit header"));
		cFYI(1, "Error decoding negTokenInit header");
		return 0;
	} else if ((cls != ASN1_APL) || (con != ASN1_CON)
		   || (tag != ASN1_EOC)) {
		cFYI(1, ("cls = %d con = %d tag = %d", cls, con, tag));
		cFYI(1, "cls = %d con = %d tag = %d", cls, con, tag);
		return 0;
	}

@@ -535,56 +535,52 @@ decode_negTokenInit(unsigned char *security_blob, int length,

	/* SPNEGO OID not present or garbled -- bail out */
	if (!rc) {
		cFYI(1, ("Error decoding negTokenInit header"));
		cFYI(1, "Error decoding negTokenInit header");
		return 0;
	}

	/* SPNEGO */
	if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
		cFYI(1, ("Error decoding negTokenInit"));
		cFYI(1, "Error decoding negTokenInit");
		return 0;
	} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
		   || (tag != ASN1_EOC)) {
		cFYI(1,
		     ("cls = %d con = %d tag = %d end = %p (%d) exit 0",
		      cls, con, tag, end, *end));
		cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 0",
		     cls, con, tag, end, *end);
		return 0;
	}

	/* negTokenInit */
	if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
		cFYI(1, ("Error decoding negTokenInit"));
		cFYI(1, "Error decoding negTokenInit");
		return 0;
	} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
		   || (tag != ASN1_SEQ)) {
		cFYI(1,
		     ("cls = %d con = %d tag = %d end = %p (%d) exit 1",
		      cls, con, tag, end, *end));
		cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 1",
		     cls, con, tag, end, *end);
		return 0;
	}

	/* sequence */
	if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
		cFYI(1, ("Error decoding 2nd part of negTokenInit"));
		cFYI(1, "Error decoding 2nd part of negTokenInit");
		return 0;
	} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
		   || (tag != ASN1_EOC)) {
		cFYI(1,
		     ("cls = %d con = %d tag = %d end = %p (%d) exit 0",
		      cls, con, tag, end, *end));
		cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 0",
		     cls, con, tag, end, *end);
		return 0;
	}

	/* sequence of */
	if (asn1_header_decode
	    (&ctx, &sequence_end, &cls, &con, &tag) == 0) {
		cFYI(1, ("Error decoding 2nd part of negTokenInit"));
		cFYI(1, "Error decoding 2nd part of negTokenInit");
		return 0;
	} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
		   || (tag != ASN1_SEQ)) {
		cFYI(1,
		     ("cls = %d con = %d tag = %d end = %p (%d) exit 1",
		      cls, con, tag, end, *end));
		cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 1",
		     cls, con, tag, end, *end);
		return 0;
	}

@@ -592,16 +588,15 @@ decode_negTokenInit(unsigned char *security_blob, int length,
	while (!asn1_eoc_decode(&ctx, sequence_end)) {
		rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
		if (!rc) {
			cFYI(1,
			     ("Error decoding negTokenInit hdr exit2"));
			cFYI(1, "Error decoding negTokenInit hdr exit2");
			return 0;
		}
		if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
			if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {

				cFYI(1, ("OID len = %d oid = 0x%lx 0x%lx "
				cFYI(1, "OID len = %d oid = 0x%lx 0x%lx "
					"0x%lx 0x%lx", oidlen, *oid,
					 *(oid + 1), *(oid + 2), *(oid + 3)));
					*(oid + 1), *(oid + 2), *(oid + 3));

				if (compare_oid(oid, oidlen, MSKRB5_OID,
						MSKRB5_OID_LEN) &&
@@ -622,7 +617,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
				kfree(oid);
			}
		} else {
			cFYI(1, ("Should be an oid what is going on?"));
			cFYI(1, "Should be an oid what is going on?");
		}
	}

@@ -632,47 +627,47 @@ decode_negTokenInit(unsigned char *security_blob, int length,
		   no mechListMic (e.g. NTLMSSP instead of KRB5) */
		if (ctx.error == ASN1_ERR_DEC_EMPTY)
			goto decode_negtoken_exit;
		cFYI(1, ("Error decoding last part negTokenInit exit3"));
		cFYI(1, "Error decoding last part negTokenInit exit3");
		return 0;
	} else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
		/* tag = 3 indicating mechListMIC */
		cFYI(1, ("Exit 4 cls = %d con = %d tag = %d end = %p (%d)",
			 cls, con, tag, end, *end));
		cFYI(1, "Exit 4 cls = %d con = %d tag = %d end = %p (%d)",
			cls, con, tag, end, *end);
		return 0;
	}

	/* sequence */
	if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
		cFYI(1, ("Error decoding last part negTokenInit exit5"));
		cFYI(1, "Error decoding last part negTokenInit exit5");
		return 0;
	} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
		   || (tag != ASN1_SEQ)) {
		cFYI(1, ("cls = %d con = %d tag = %d end = %p (%d)",
			cls, con, tag, end, *end));
		cFYI(1, "cls = %d con = %d tag = %d end = %p (%d)",
			cls, con, tag, end, *end);
	}

	/* sequence of */
	if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
		cFYI(1, ("Error decoding last part negTokenInit exit 7"));
		cFYI(1, "Error decoding last part negTokenInit exit 7");
		return 0;
	} else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
		cFYI(1, ("Exit 8 cls = %d con = %d tag = %d end = %p (%d)",
			 cls, con, tag, end, *end));
		cFYI(1, "Exit 8 cls = %d con = %d tag = %d end = %p (%d)",
			cls, con, tag, end, *end);
		return 0;
	}

	/* general string */
	if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
		cFYI(1, ("Error decoding last part negTokenInit exit9"));
		cFYI(1, "Error decoding last part negTokenInit exit9");
		return 0;
	} else if ((cls != ASN1_UNI) || (con != ASN1_PRI)
		   || (tag != ASN1_GENSTR)) {
		cFYI(1, ("Exit10 cls = %d con = %d tag = %d end = %p (%d)",
			 cls, con, tag, end, *end));
		cFYI(1, "Exit10 cls = %d con = %d tag = %d end = %p (%d)",
			cls, con, tag, end, *end);
		return 0;
	}
	cFYI(1, ("Need to call asn1_octets_decode() function for %s",
		 ctx.pointer));	/* is this UTF-8 or ASCII? */
	cFYI(1, "Need to call asn1_octets_decode() function for %s",
		ctx.pointer);	/* is this UTF-8 or ASCII? */
decode_negtoken_exit:
	if (use_kerberos)
		*secType = Kerberos;
+17 −17
Original line number Diff line number Diff line
@@ -60,10 +60,10 @@ cifs_dump_mem(char *label, void *data, int length)
#ifdef CONFIG_CIFS_DEBUG2
void cifs_dump_detail(struct smb_hdr *smb)
{
	cERROR(1, ("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
	cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
		  smb->Command, smb->Status.CifsError,
		  smb->Flags, smb->Flags2, smb->Mid, smb->Pid));
	cERROR(1, ("smb buf %p len %d", smb, smbCalcSize_LE(smb)));
		  smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
	cERROR(1, "smb buf %p len %d", smb, smbCalcSize_LE(smb));
}


@@ -75,25 +75,25 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
	if (server == NULL)
		return;

	cERROR(1, ("Dump pending requests:"));
	cERROR(1, "Dump pending requests:");
	spin_lock(&GlobalMid_Lock);
	list_for_each(tmp, &server->pending_mid_q) {
		mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
		cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
		cERROR(1, "State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
			mid_entry->midState,
			(int)mid_entry->command,
			mid_entry->pid,
			mid_entry->tsk,
			mid_entry->mid));
			mid_entry->mid);
#ifdef CONFIG_CIFS_STATS2
		cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
		cERROR(1, "IsLarge: %d buf: %p time rcv: %ld now: %ld",
			mid_entry->largeBuf,
			mid_entry->resp_buf,
			mid_entry->when_received,
			jiffies));
			jiffies);
#endif /* STATS2 */
		cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
			  mid_entry->multiEnd));
		cERROR(1, "IsMult: %d IsEnd: %d", mid_entry->multiRsp,
			  mid_entry->multiEnd);
		if (mid_entry->resp_buf) {
			cifs_dump_detail(mid_entry->resp_buf);
			cifs_dump_mem("existing buf: ",
@@ -750,7 +750,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
			extended_security = CIFSSEC_MAX;
			return count;
		} else if (!isdigit(c)) {
			cERROR(1, ("invalid flag %c", c));
			cERROR(1, "invalid flag %c", c);
			return -EINVAL;
		}
	}
@@ -758,16 +758,16 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,

	flags = simple_strtoul(flags_string, NULL, 0);

	cFYI(1, ("sec flags 0x%x", flags));
	cFYI(1, "sec flags 0x%x", flags);

	if (flags <= 0)  {
		cERROR(1, ("invalid security flags %s", flags_string));
		cERROR(1, "invalid security flags %s", flags_string);
		return -EINVAL;
	}

	if (flags & ~CIFSSEC_MASK) {
		cERROR(1, ("attempt to set unsupported security flags 0x%x",
			flags & ~CIFSSEC_MASK));
		cERROR(1, "attempt to set unsupported security flags 0x%x",
			flags & ~CIFSSEC_MASK);
		return -EINVAL;
	}
	/* flags look ok - update the global security flags for cifs module */
@@ -775,9 +775,9 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
	if (extended_security & CIFSSEC_MUST_SIGN) {
		/* requiring signing implies signing is allowed */
		extended_security |= CIFSSEC_MAY_SIGN;
		cFYI(1, ("packet signing now required"));
		cFYI(1, "packet signing now required");
	} else if ((extended_security & CIFSSEC_MAY_SIGN) == 0) {
		cFYI(1, ("packet signing disabled"));
		cFYI(1, "packet signing disabled");
	}
	/* BB should we turn on MAY flags for other MUST options? */
	return count;
+31 −11
Original line number Diff line number Diff line
@@ -43,34 +43,54 @@ void dump_smb(struct smb_hdr *, int);
 */
#ifdef CIFS_DEBUG


/* information message: e.g., configuration, major event */
extern int cifsFYI;
#define cifsfyi(format,arg...) if (cifsFYI & CIFS_INFO) printk(KERN_DEBUG " " __FILE__ ": " format "\n" "" , ## arg)
#define cifsfyi(fmt, arg...)						\
do {									\
	if (cifsFYI & CIFS_INFO)					\
		printk(KERN_DEBUG "%s: " fmt "\n", __FILE__, ##arg);	\
} while (0)

#define cFYI(button,prspec) if (button) cifsfyi prspec
#define cFYI(set, fmt, arg...)			\
do {						\
	if (set)				\
		cifsfyi(fmt, ##arg);		\
} while (0)

#define cifswarn(format, arg...) printk(KERN_WARNING ": " format "\n" , ## arg)
#define cifswarn(fmt, arg...)			\
	printk(KERN_WARNING fmt "\n", ##arg)

/* debug event message: */
extern int cifsERROR;

#define cEVENT(format,arg...) if (cifsERROR) printk(KERN_EVENT __FILE__ ": " format "\n" , ## arg)
#define cEVENT(fmt, arg...)						\
do {									\
	if (cifsERROR)							\
		printk(KERN_EVENT "%s: " fmt "\n", __FILE__, ##arg);	\
} while (0)

/* error event message: e.g., i/o error */
#define cifserror(format,arg...) if (cifsERROR) printk(KERN_ERR " CIFS VFS: " format "\n" "" , ## arg)
#define cifserror(fmt, arg...)					\
do {								\
	if (cifsERROR)						\
		printk(KERN_ERR "CIFS VFS: " fmt "\n", ##arg);	\
} while (0)

#define cERROR(button, prspec) if (button) cifserror prspec
#define cERROR(set, fmt, arg...)		\
do {						\
	if (set)				\
		cifserror(fmt, ##arg);		\
} while (0)

/*
 *	debug OFF
 *	---------
 */
#else		/* _CIFS_DEBUG */
#define cERROR(button, prspec)
#define cEVENT(format, arg...)
#define cFYI(button, prspec)
#define cifserror(format, arg...)
#define cERROR(set, fmt, arg...)
#define cEVENT(fmt, arg...)
#define cFYI(set, fmt, arg...)
#define cifserror(fmt, arg...)
#endif		/* _CIFS_DEBUG */

#endif				/* _H_CIFS_DEBUG */
+17 −17
Original line number Diff line number Diff line
@@ -85,8 +85,8 @@ static char *cifs_get_share_name(const char *node_name)
	/* find server name end */
	pSep = memchr(UNC+2, '\\', len-2);
	if (!pSep) {
		cERROR(1, ("%s: no server name end in node name: %s",
			__func__, node_name));
		cERROR(1, "%s: no server name end in node name: %s",
			__func__, node_name);
		kfree(UNC);
		return ERR_PTR(-EINVAL);
	}
@@ -142,8 +142,8 @@ char *cifs_compose_mount_options(const char *sb_mountdata,

	rc = dns_resolve_server_name_to_ip(*devname, &srvIP);
	if (rc != 0) {
		cERROR(1, ("%s: Failed to resolve server part of %s to IP: %d",
			  __func__, *devname, rc));
		cERROR(1, "%s: Failed to resolve server part of %s to IP: %d",
			  __func__, *devname, rc);
		goto compose_mount_options_err;
	}
	/* md_len = strlen(...) + 12 for 'sep+prefixpath='
@@ -217,8 +217,8 @@ char *cifs_compose_mount_options(const char *sb_mountdata,
		strcat(mountdata, fullpath + ref->path_consumed);
	}

	/*cFYI(1,("%s: parent mountdata: %s", __func__,sb_mountdata));*/
	/*cFYI(1, ("%s: submount mountdata: %s", __func__, mountdata ));*/
	/*cFYI(1, "%s: parent mountdata: %s", __func__,sb_mountdata);*/
	/*cFYI(1, "%s: submount mountdata: %s", __func__, mountdata );*/

compose_mount_options_out:
	kfree(srvIP);
@@ -294,11 +294,11 @@ static int add_mount_helper(struct vfsmount *newmnt, struct nameidata *nd,

static void dump_referral(const struct dfs_info3_param *ref)
{
	cFYI(1, ("DFS: ref path: %s", ref->path_name));
	cFYI(1, ("DFS: node path: %s", ref->node_name));
	cFYI(1, ("DFS: fl: %hd, srv_type: %hd", ref->flags, ref->server_type));
	cFYI(1, ("DFS: ref_flags: %hd, path_consumed: %hd", ref->ref_flag,
				ref->path_consumed));
	cFYI(1, "DFS: ref path: %s", ref->path_name);
	cFYI(1, "DFS: node path: %s", ref->node_name);
	cFYI(1, "DFS: fl: %hd, srv_type: %hd", ref->flags, ref->server_type);
	cFYI(1, "DFS: ref_flags: %hd, path_consumed: %hd", ref->ref_flag,
				ref->path_consumed);
}


@@ -314,7 +314,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
	int rc = 0;
	struct vfsmount *mnt = ERR_PTR(-ENOENT);

	cFYI(1, ("in %s", __func__));
	cFYI(1, "in %s", __func__);
	BUG_ON(IS_ROOT(dentry));

	xid = GetXid();
@@ -352,15 +352,15 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
		/* connect to a node */
		len = strlen(referrals[i].node_name);
		if (len < 2) {
			cERROR(1, ("%s: Net Address path too short: %s",
					__func__, referrals[i].node_name));
			cERROR(1, "%s: Net Address path too short: %s",
					__func__, referrals[i].node_name);
			rc = -EINVAL;
			goto out_err;
		}
		mnt = cifs_dfs_do_refmount(nd->path.mnt,
				nd->path.dentry, referrals + i);
		cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p", __func__,
					referrals[i].node_name, mnt));
		cFYI(1, "%s: cifs_dfs_do_refmount:%s , mnt:%p", __func__,
					referrals[i].node_name, mnt);

		/* complete mount procedure if we accured submount */
		if (!IS_ERR(mnt))
@@ -378,7 +378,7 @@ out:
	FreeXid(xid);
	free_dfs_info_array(referrals, num_referrals);
	kfree(full_path);
	cFYI(1, ("leaving %s" , __func__));
	cFYI(1, "leaving %s" , __func__);
	return ERR_PTR(rc);
out_err:
	path_put(&nd->path);
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
	dp = description + strlen(description);
	sprintf(dp, ";pid=0x%x", current->pid);

	cFYI(1, ("key description = %s", description));
	cFYI(1, "key description = %s", description);
	spnego_key = request_key(&cifs_spnego_key_type, description, "");

#ifdef CONFIG_CIFS_DEBUG2
Loading