Skip to content

Commit b6b38f7

Browse files
JoePerchesSteve French
authored andcommitted
[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: Joe Perches <joe@perches.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent 315e995 commit b6b38f7

25 files changed

Lines changed: 845 additions & 835 deletions

‎fs/cifs/asn1.c‎

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,11 @@ decode_negTokenInit(unsigned char *security_blob, int length,
510510

511511
/* GSSAPI header */
512512
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
513-
cFYI(1, ("Error decoding negTokenInit header"));
513+
cFYI(1, "Error decoding negTokenInit header");
514514
return 0;
515515
} else if ((cls != ASN1_APL) || (con != ASN1_CON)
516516
|| (tag != ASN1_EOC)) {
517-
cFYI(1, ("cls = %d con = %d tag = %d", cls, con, tag));
517+
cFYI(1, "cls = %d con = %d tag = %d", cls, con, tag);
518518
return 0;
519519
}
520520

@@ -535,73 +535,68 @@ decode_negTokenInit(unsigned char *security_blob, int length,
535535

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

542542
/* SPNEGO */
543543
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
544-
cFYI(1, ("Error decoding negTokenInit"));
544+
cFYI(1, "Error decoding negTokenInit");
545545
return 0;
546546
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
547547
|| (tag != ASN1_EOC)) {
548-
cFYI(1,
549-
("cls = %d con = %d tag = %d end = %p (%d) exit 0",
550-
cls, con, tag, end, *end));
548+
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 0",
549+
cls, con, tag, end, *end);
551550
return 0;
552551
}
553552

554553
/* negTokenInit */
555554
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
556-
cFYI(1, ("Error decoding negTokenInit"));
555+
cFYI(1, "Error decoding negTokenInit");
557556
return 0;
558557
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
559558
|| (tag != ASN1_SEQ)) {
560-
cFYI(1,
561-
("cls = %d con = %d tag = %d end = %p (%d) exit 1",
562-
cls, con, tag, end, *end));
559+
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 1",
560+
cls, con, tag, end, *end);
563561
return 0;
564562
}
565563

566564
/* sequence */
567565
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
568-
cFYI(1, ("Error decoding 2nd part of negTokenInit"));
566+
cFYI(1, "Error decoding 2nd part of negTokenInit");
569567
return 0;
570568
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
571569
|| (tag != ASN1_EOC)) {
572-
cFYI(1,
573-
("cls = %d con = %d tag = %d end = %p (%d) exit 0",
574-
cls, con, tag, end, *end));
570+
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 0",
571+
cls, con, tag, end, *end);
575572
return 0;
576573
}
577574

578575
/* sequence of */
579576
if (asn1_header_decode
580577
(&ctx, &sequence_end, &cls, &con, &tag) == 0) {
581-
cFYI(1, ("Error decoding 2nd part of negTokenInit"));
578+
cFYI(1, "Error decoding 2nd part of negTokenInit");
582579
return 0;
583580
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
584581
|| (tag != ASN1_SEQ)) {
585-
cFYI(1,
586-
("cls = %d con = %d tag = %d end = %p (%d) exit 1",
587-
cls, con, tag, end, *end));
582+
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 1",
583+
cls, con, tag, end, *end);
588584
return 0;
589585
}
590586

591587
/* list of security mechanisms */
592588
while (!asn1_eoc_decode(&ctx, sequence_end)) {
593589
rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
594590
if (!rc) {
595-
cFYI(1,
596-
("Error decoding negTokenInit hdr exit2"));
591+
cFYI(1, "Error decoding negTokenInit hdr exit2");
597592
return 0;
598593
}
599594
if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
600595
if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {
601596

602-
cFYI(1, ("OID len = %d oid = 0x%lx 0x%lx "
603-
"0x%lx 0x%lx", oidlen, *oid,
604-
*(oid + 1), *(oid + 2), *(oid + 3)));
597+
cFYI(1, "OID len = %d oid = 0x%lx 0x%lx "
598+
"0x%lx 0x%lx", oidlen, *oid,
599+
*(oid + 1), *(oid + 2), *(oid + 3));
605600

606601
if (compare_oid(oid, oidlen, MSKRB5_OID,
607602
MSKRB5_OID_LEN) &&
@@ -622,7 +617,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
622617
kfree(oid);
623618
}
624619
} else {
625-
cFYI(1, ("Should be an oid what is going on?"));
620+
cFYI(1, "Should be an oid what is going on?");
626621
}
627622
}
628623

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

644639
/* sequence */
645640
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
646-
cFYI(1, ("Error decoding last part negTokenInit exit5"));
641+
cFYI(1, "Error decoding last part negTokenInit exit5");
647642
return 0;
648643
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
649644
|| (tag != ASN1_SEQ)) {
650-
cFYI(1, ("cls = %d con = %d tag = %d end = %p (%d)",
651-
cls, con, tag, end, *end));
645+
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d)",
646+
cls, con, tag, end, *end);
652647
}
653648

654649
/* sequence of */
655650
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
656-
cFYI(1, ("Error decoding last part negTokenInit exit 7"));
651+
cFYI(1, "Error decoding last part negTokenInit exit 7");
657652
return 0;
658653
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
659-
cFYI(1, ("Exit 8 cls = %d con = %d tag = %d end = %p (%d)",
660-
cls, con, tag, end, *end));
654+
cFYI(1, "Exit 8 cls = %d con = %d tag = %d end = %p (%d)",
655+
cls, con, tag, end, *end);
661656
return 0;
662657
}
663658

664659
/* general string */
665660
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
666-
cFYI(1, ("Error decoding last part negTokenInit exit9"));
661+
cFYI(1, "Error decoding last part negTokenInit exit9");
667662
return 0;
668663
} else if ((cls != ASN1_UNI) || (con != ASN1_PRI)
669664
|| (tag != ASN1_GENSTR)) {
670-
cFYI(1, ("Exit10 cls = %d con = %d tag = %d end = %p (%d)",
671-
cls, con, tag, end, *end));
665+
cFYI(1, "Exit10 cls = %d con = %d tag = %d end = %p (%d)",
666+
cls, con, tag, end, *end);
672667
return 0;
673668
}
674-
cFYI(1, ("Need to call asn1_octets_decode() function for %s",
675-
ctx.pointer)); /* is this UTF-8 or ASCII? */
669+
cFYI(1, "Need to call asn1_octets_decode() function for %s",
670+
ctx.pointer); /* is this UTF-8 or ASCII? */
676671
decode_negtoken_exit:
677672
if (use_kerberos)
678673
*secType = Kerberos;

‎fs/cifs/cifs_debug.c‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ cifs_dump_mem(char *label, void *data, int length)
6060
#ifdef CONFIG_CIFS_DEBUG2
6161
void cifs_dump_detail(struct smb_hdr *smb)
6262
{
63-
cERROR(1, ("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
63+
cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
6464
smb->Command, smb->Status.CifsError,
65-
smb->Flags, smb->Flags2, smb->Mid, smb->Pid));
66-
cERROR(1, ("smb buf %p len %d", smb, smbCalcSize_LE(smb)));
65+
smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
66+
cERROR(1, "smb buf %p len %d", smb, smbCalcSize_LE(smb));
6767
}
6868

6969

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

78-
cERROR(1, ("Dump pending requests:"));
78+
cERROR(1, "Dump pending requests:");
7979
spin_lock(&GlobalMid_Lock);
8080
list_for_each(tmp, &server->pending_mid_q) {
8181
mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
82-
cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
82+
cERROR(1, "State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
8383
mid_entry->midState,
8484
(int)mid_entry->command,
8585
mid_entry->pid,
8686
mid_entry->tsk,
87-
mid_entry->mid));
87+
mid_entry->mid);
8888
#ifdef CONFIG_CIFS_STATS2
89-
cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
89+
cERROR(1, "IsLarge: %d buf: %p time rcv: %ld now: %ld",
9090
mid_entry->largeBuf,
9191
mid_entry->resp_buf,
9292
mid_entry->when_received,
93-
jiffies));
93+
jiffies);
9494
#endif /* STATS2 */
95-
cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
96-
mid_entry->multiEnd));
95+
cERROR(1, "IsMult: %d IsEnd: %d", mid_entry->multiRsp,
96+
mid_entry->multiEnd);
9797
if (mid_entry->resp_buf) {
9898
cifs_dump_detail(mid_entry->resp_buf);
9999
cifs_dump_mem("existing buf: ",
@@ -750,34 +750,34 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
750750
extended_security = CIFSSEC_MAX;
751751
return count;
752752
} else if (!isdigit(c)) {
753-
cERROR(1, ("invalid flag %c", c));
753+
cERROR(1, "invalid flag %c", c);
754754
return -EINVAL;
755755
}
756756
}
757757
/* else we have a number */
758758

759759
flags = simple_strtoul(flags_string, NULL, 0);
760760

761-
cFYI(1, ("sec flags 0x%x", flags));
761+
cFYI(1, "sec flags 0x%x", flags);
762762

763763
if (flags <= 0) {
764-
cERROR(1, ("invalid security flags %s", flags_string));
764+
cERROR(1, "invalid security flags %s", flags_string);
765765
return -EINVAL;
766766
}
767767

768768
if (flags & ~CIFSSEC_MASK) {
769-
cERROR(1, ("attempt to set unsupported security flags 0x%x",
770-
flags & ~CIFSSEC_MASK));
769+
cERROR(1, "attempt to set unsupported security flags 0x%x",
770+
flags & ~CIFSSEC_MASK);
771771
return -EINVAL;
772772
}
773773
/* flags look ok - update the global security flags for cifs module */
774774
extended_security = flags;
775775
if (extended_security & CIFSSEC_MUST_SIGN) {
776776
/* requiring signing implies signing is allowed */
777777
extended_security |= CIFSSEC_MAY_SIGN;
778-
cFYI(1, ("packet signing now required"));
778+
cFYI(1, "packet signing now required");
779779
} else if ((extended_security & CIFSSEC_MAY_SIGN) == 0) {
780-
cFYI(1, ("packet signing disabled"));
780+
cFYI(1, "packet signing disabled");
781781
}
782782
/* BB should we turn on MAY flags for other MUST options? */
783783
return count;

‎fs/cifs/cifs_debug.h‎

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,54 @@ void dump_smb(struct smb_hdr *, int);
4343
*/
4444
#ifdef CIFS_DEBUG
4545

46-
4746
/* information message: e.g., configuration, major event */
4847
extern int cifsFYI;
49-
#define cifsfyi(format,arg...) if (cifsFYI & CIFS_INFO) printk(KERN_DEBUG " " __FILE__ ": " format "\n" "" , ## arg)
48+
#define cifsfyi(fmt, arg...) \
49+
do { \
50+
if (cifsFYI & CIFS_INFO) \
51+
printk(KERN_DEBUG "%s: " fmt "\n", __FILE__, ##arg); \
52+
} while (0)
5053

51-
#define cFYI(button,prspec) if (button) cifsfyi prspec
54+
#define cFYI(set, fmt, arg...) \
55+
do { \
56+
if (set) \
57+
cifsfyi(fmt, ##arg); \
58+
} while (0)
5259

53-
#define cifswarn(format, arg...) printk(KERN_WARNING ": " format "\n" , ## arg)
60+
#define cifswarn(fmt, arg...) \
61+
printk(KERN_WARNING fmt "\n", ##arg)
5462

5563
/* debug event message: */
5664
extern int cifsERROR;
5765

58-
#define cEVENT(format,arg...) if (cifsERROR) printk(KERN_EVENT __FILE__ ": " format "\n" , ## arg)
66+
#define cEVENT(fmt, arg...) \
67+
do { \
68+
if (cifsERROR) \
69+
printk(KERN_EVENT "%s: " fmt "\n", __FILE__, ##arg); \
70+
} while (0)
5971

6072
/* error event message: e.g., i/o error */
61-
#define cifserror(format,arg...) if (cifsERROR) printk(KERN_ERR " CIFS VFS: " format "\n" "" , ## arg)
73+
#define cifserror(fmt, arg...) \
74+
do { \
75+
if (cifsERROR) \
76+
printk(KERN_ERR "CIFS VFS: " fmt "\n", ##arg); \
77+
} while (0)
6278

63-
#define cERROR(button, prspec) if (button) cifserror prspec
79+
#define cERROR(set, fmt, arg...) \
80+
do { \
81+
if (set) \
82+
cifserror(fmt, ##arg); \
83+
} while (0)
6484

6585
/*
6686
* debug OFF
6787
* ---------
6888
*/
6989
#else /* _CIFS_DEBUG */
70-
#define cERROR(button, prspec)
71-
#define cEVENT(format, arg...)
72-
#define cFYI(button, prspec)
73-
#define cifserror(format, arg...)
90+
#define cERROR(set, fmt, arg...)
91+
#define cEVENT(fmt, arg...)
92+
#define cFYI(set, fmt, arg...)
93+
#define cifserror(fmt, arg...)
7494
#endif /* _CIFS_DEBUG */
7595

7696
#endif /* _H_CIFS_DEBUG */

0 commit comments

Comments
 (0)