@@ -466,15 +466,14 @@ build_signing_ctxt(struct smb2_signing_capabilities *pneg_ctxt)
466
466
/*
467
467
* Context Data length must be rounded to multiple of 8 for some servers
468
468
*/
469
- pneg_ctxt -> DataLength = cpu_to_le16 (DIV_ROUND_UP (
470
- sizeof (struct smb2_signing_capabilities ) -
471
- sizeof (struct smb2_neg_context ) +
472
- (num_algs * 2 /* sizeof u16 */ ), 8 ) * 8 );
469
+ pneg_ctxt -> DataLength = cpu_to_le16 (ALIGN (sizeof (struct smb2_signing_capabilities ) -
470
+ sizeof (struct smb2_neg_context ) +
471
+ (num_algs * sizeof (u16 )), 8 ));
473
472
pneg_ctxt -> SigningAlgorithmCount = cpu_to_le16 (num_algs );
474
473
pneg_ctxt -> SigningAlgorithms [0 ] = cpu_to_le16 (SIGNING_ALG_AES_CMAC );
475
474
476
- ctxt_len += 2 /* sizeof le16 */ * num_algs ;
477
- ctxt_len = DIV_ROUND_UP (ctxt_len , 8 ) * 8 ;
475
+ ctxt_len += sizeof ( __le16 ) * num_algs ;
476
+ ctxt_len = ALIGN (ctxt_len , 8 );
478
477
return ctxt_len ;
479
478
/* TBD add SIGNING_ALG_AES_GMAC and/or SIGNING_ALG_HMAC_SHA256 */
480
479
}
@@ -511,8 +510,7 @@ build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname)
511
510
/* copy up to max of first 100 bytes of server name to NetName field */
512
511
pneg_ctxt -> DataLength = cpu_to_le16 (2 * cifs_strtoUTF16 (pneg_ctxt -> NetName , hostname , 100 , cp ));
513
512
/* context size is DataLength + minimal smb2_neg_context */
514
- return DIV_ROUND_UP (le16_to_cpu (pneg_ctxt -> DataLength ) +
515
- sizeof (struct smb2_neg_context ), 8 ) * 8 ;
513
+ return ALIGN (le16_to_cpu (pneg_ctxt -> DataLength ) + sizeof (struct smb2_neg_context ), 8 );
516
514
}
517
515
518
516
static void
@@ -557,18 +555,18 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
557
555
* round up total_len of fixed part of SMB3 negotiate request to 8
558
556
* byte boundary before adding negotiate contexts
559
557
*/
560
- * total_len = roundup (* total_len , 8 );
558
+ * total_len = ALIGN (* total_len , 8 );
561
559
562
560
pneg_ctxt = (* total_len ) + (char * )req ;
563
561
req -> NegotiateContextOffset = cpu_to_le32 (* total_len );
564
562
565
563
build_preauth_ctxt ((struct smb2_preauth_neg_context * )pneg_ctxt );
566
- ctxt_len = DIV_ROUND_UP (sizeof (struct smb2_preauth_neg_context ), 8 ) * 8 ;
564
+ ctxt_len = ALIGN (sizeof (struct smb2_preauth_neg_context ), 8 );
567
565
* total_len += ctxt_len ;
568
566
pneg_ctxt += ctxt_len ;
569
567
570
568
build_encrypt_ctxt ((struct smb2_encryption_neg_context * )pneg_ctxt );
571
- ctxt_len = DIV_ROUND_UP (sizeof (struct smb2_encryption_neg_context ), 8 ) * 8 ;
569
+ ctxt_len = ALIGN (sizeof (struct smb2_encryption_neg_context ), 8 );
572
570
* total_len += ctxt_len ;
573
571
pneg_ctxt += ctxt_len ;
574
572
@@ -595,9 +593,7 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
595
593
if (server -> compress_algorithm ) {
596
594
build_compression_ctxt ((struct smb2_compression_capabilities_context * )
597
595
pneg_ctxt );
598
- ctxt_len = DIV_ROUND_UP (
599
- sizeof (struct smb2_compression_capabilities_context ),
600
- 8 ) * 8 ;
596
+ ctxt_len = ALIGN (sizeof (struct smb2_compression_capabilities_context ), 8 );
601
597
* total_len += ctxt_len ;
602
598
pneg_ctxt += ctxt_len ;
603
599
neg_context_count ++ ;
@@ -780,7 +776,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp,
780
776
if (rc )
781
777
break ;
782
778
/* offsets must be 8 byte aligned */
783
- clen = (clen + 7 ) & ~ 0x7 ;
779
+ clen = ALIGN (clen , 8 ) ;
784
780
offset += clen + sizeof (struct smb2_neg_context );
785
781
len_of_ctxts -= clen ;
786
782
}
@@ -2426,7 +2422,7 @@ create_sd_buf(umode_t mode, bool set_owner, unsigned int *len)
2426
2422
unsigned int group_offset = 0 ;
2427
2423
struct smb3_acl acl ;
2428
2424
2429
- * len = roundup (sizeof (struct crt_sd_ctxt ) + (sizeof (struct cifs_ace ) * 4 ), 8 );
2425
+ * len = round_up (sizeof (struct crt_sd_ctxt ) + (sizeof (struct cifs_ace ) * 4 ), 8 );
2430
2426
2431
2427
if (set_owner ) {
2432
2428
/* sizeof(struct owner_group_sids) is already multiple of 8 so no need to round */
@@ -2500,7 +2496,7 @@ create_sd_buf(umode_t mode, bool set_owner, unsigned int *len)
2500
2496
memcpy (aclptr , & acl , sizeof (struct smb3_acl ));
2501
2497
2502
2498
buf -> ccontext .DataLength = cpu_to_le32 (ptr - (__u8 * )& buf -> sd );
2503
- * len = roundup ( ptr - (__u8 * )buf , 8 );
2499
+ * len = round_up (( unsigned int )( ptr - (__u8 * )buf ) , 8 );
2504
2500
2505
2501
return buf ;
2506
2502
}
@@ -2594,7 +2590,7 @@ alloc_path_with_tree_prefix(__le16 **out_path, int *out_size, int *out_len,
2594
2590
* final path needs to be 8-byte aligned as specified in
2595
2591
* MS-SMB2 2.2.13 SMB2 CREATE Request.
2596
2592
*/
2597
- * out_size = roundup (* out_len * sizeof (__le16 ), 8 );
2593
+ * out_size = round_up (* out_len * sizeof (__le16 ), 8 );
2598
2594
* out_path = kzalloc (* out_size + sizeof (__le16 ) /* null */ , GFP_KERNEL );
2599
2595
if (!* out_path )
2600
2596
return - ENOMEM ;
@@ -2839,9 +2835,7 @@ SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
2839
2835
uni_path_len = (2 * UniStrnlen ((wchar_t * )path , PATH_MAX )) + 2 ;
2840
2836
/* MUST set path len (NameLength) to 0 opening root of share */
2841
2837
req -> NameLength = cpu_to_le16 (uni_path_len - 2 );
2842
- copy_size = uni_path_len ;
2843
- if (copy_size % 8 != 0 )
2844
- copy_size = roundup (copy_size , 8 );
2838
+ copy_size = round_up (uni_path_len , 8 );
2845
2839
copy_path = kzalloc (copy_size , GFP_KERNEL );
2846
2840
if (!copy_path )
2847
2841
return - ENOMEM ;
@@ -4103,7 +4097,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
4103
4097
if (request_type & CHAINED_REQUEST ) {
4104
4098
if (!(request_type & END_OF_CHAIN )) {
4105
4099
/* next 8-byte aligned request */
4106
- * total_len = DIV_ROUND_UP (* total_len , 8 ) * 8 ;
4100
+ * total_len = ALIGN (* total_len , 8 );
4107
4101
shdr -> NextCommand = cpu_to_le32 (* total_len );
4108
4102
} else /* END_OF_CHAIN */
4109
4103
shdr -> NextCommand = 0 ;
0 commit comments