linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (12 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] apparmor: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:02 ` [PATCH] btrfs: " Thomas Meyer
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: tytso, adilger.kernel, linux-ext4, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/ext4/extents.c b/fs/ext4/extents.c
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5242,7 +5242,7 @@ ext4_ext_shift_path_extents(struct ext4_
 {
 	int depth, err = 0;
 	struct ext4_extent *ex_start, *ex_last;
-	bool update = 0;
+	bool update = false;
 	depth = path->p_depth;
 
 	while (depth >= 0) {
@@ -5258,7 +5258,7 @@ ext4_ext_shift_path_extents(struct ext4_
 				goto out;
 
 			if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr))
-				update = 1;
+				update = true;
 
 			while (ex_start <= ex_last) {
 				if (SHIFT == SHIFT_LEFT) {

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] afs: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (5 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] pstore: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:02 ` [PATCH] xfs: " Thomas Meyer
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: dhowells, linux-afs, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/afs/cache.c b/fs/afs/cache.c
--- a/fs/afs/cache.c
+++ b/fs/afs/cache.c
@@ -195,7 +195,7 @@ enum fscache_checkaux afs_vlocation_cach
 	 * VL record from the cache */
 	if (!vlocation->valid || vlocation->vldb.rtime == cvldb->rtime) {
 		memcpy((uint8_t *)&vlocation->vldb.nservers, buffer, dlen);
-		vlocation->valid = 1;
+		vlocation->valid = true;
 		_leave(" = SUCCESS [c->m]");
 		return FSCACHE_CHECKAUX_OKAY;
 	}
diff -u -p a/fs/afs/super.c b/fs/afs/super.c
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -211,7 +211,7 @@ static int afs_parse_options(struct afs_
 			break;
 
 		case afs_opt_rwpath:
-			params->rwpath = 1;
+			params->rwpath = true;
 			break;
 
 		case afs_opt_vol:
@@ -219,7 +219,7 @@ static int afs_parse_options(struct afs_
 			break;
 
 		case afs_opt_autocell:
-			params->autocell = 1;
+			params->autocell = true;
 			break;
 
 		default:
diff -u -p a/fs/afs/vlocation.c b/fs/afs/vlocation.c
--- a/fs/afs/vlocation.c
+++ b/fs/afs/vlocation.c
@@ -154,7 +154,7 @@ out:
 		printk(KERN_NOTICE "kAFS:"
 		       " Active volume no longer valid '%s'\n",
 		       vl->vldb.name);
-		vl->valid = 0;
+		vl->valid = false;
 		ret = -ENOMEDIUM;
 	}
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] cifs: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
  2017-10-07 14:02 ` [PATCH] f2fs: Fix bool initialization/comparison Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-10  1:14   ` Nico Kadel-Garcia
  2017-10-07 14:02 ` [PATCH] ima: " Thomas Meyer
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: sfrench, linux-cifs, samba-technical, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -370,7 +370,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb,
 		else
 			is_group = false;
 
-		if (is_well_known_sid(psid, &unix_id, is_group) == false)
+		if (!is_well_known_sid(psid, &unix_id, is_group))
 			goto try_upcall_to_get_id;
 
 		if (is_group) {
diff -u -p a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -4508,7 +4508,7 @@ findFirstRetry:
 				psrch_inf->unicode = false;
 
 			psrch_inf->ntwrk_buf_start = (char *)pSMBr;
-			psrch_inf->smallBuf = 0;
+			psrch_inf->smallBuf = false;
 			psrch_inf->srch_entries_start =
 				(char *) &pSMBr->hdr.Protocol +
 					le16_to_cpu(pSMBr->t2.DataOffset);
@@ -4642,7 +4642,7 @@ int CIFSFindNext(const unsigned int xid,
 				cifs_buf_release(psrch_inf->ntwrk_buf_start);
 			psrch_inf->srch_entries_start = response_data;
 			psrch_inf->ntwrk_buf_start = (char *)pSMB;
-			psrch_inf->smallBuf = 0;
+			psrch_inf->smallBuf = false;
 			if (parms->EndofSearch)
 				psrch_inf->endOfSearch = true;
 			else
diff -u -p a/fs/cifs/connect.c b/fs/cifs/connect.c
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1081,7 +1081,7 @@ static int cifs_parse_security_flavors(c
 		break;
 #endif
 	case Opt_sec_none:
-		vol->nullauth = 1;
+		vol->nullauth = true;
 		break;
 	default:
 		cifs_dbg(VFS, "bad security option: %s\n", value);
@@ -1265,9 +1265,9 @@ cifs_parse_mount_options(const char *mou
 
 	/* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */
 	/* default is always to request posix paths. */
-	vol->posix_paths = 1;
+	vol->posix_paths = true;
 	/* default to using server inode numbers where available */
-	vol->server_ino = 1;
+	vol->server_ino = true;
 
 	/* default is to use strict cifs caching semantics */
 	vol->strict_io = true;
@@ -1333,10 +1333,10 @@ cifs_parse_mount_options(const char *mou
 
 		/* Boolean values */
 		case Opt_user_xattr:
-			vol->no_xattr = 0;
+			vol->no_xattr = false;
 			break;
 		case Opt_nouser_xattr:
-			vol->no_xattr = 1;
+			vol->no_xattr = true;
 			break;
 		case Opt_forceuid:
 			override_uid = 1;
@@ -1351,22 +1351,22 @@ cifs_parse_mount_options(const char *mou
 			override_gid = 0;
 			break;
 		case Opt_noblocksend:
-			vol->noblocksnd = 1;
+			vol->noblocksnd = true;
 			break;
 		case Opt_noautotune:
-			vol->noautotune = 1;
+			vol->noautotune = true;
 			break;
 		case Opt_hard:
-			vol->retry = 1;
+			vol->retry = true;
 			break;
 		case Opt_soft:
-			vol->retry = 0;
+			vol->retry = false;
 			break;
 		case Opt_perm:
-			vol->noperm = 0;
+			vol->noperm = false;
 			break;
 		case Opt_noperm:
-			vol->noperm = 1;
+			vol->noperm = true;
 			break;
 		case Opt_mapchars:
 			vol->sfu_remap = true;
@@ -1383,31 +1383,31 @@ cifs_parse_mount_options(const char *mou
 			vol->remap = false;
 			break;
 		case Opt_sfu:
-			vol->sfu_emul = 1;
+			vol->sfu_emul = true;
 			break;
 		case Opt_nosfu:
-			vol->sfu_emul = 0;
+			vol->sfu_emul = false;
 			break;
 		case Opt_nodfs:
-			vol->nodfs = 1;
+			vol->nodfs = true;
 			break;
 		case Opt_posixpaths:
-			vol->posix_paths = 1;
+			vol->posix_paths = true;
 			break;
 		case Opt_noposixpaths:
-			vol->posix_paths = 0;
+			vol->posix_paths = false;
 			break;
 		case Opt_nounix:
-			vol->no_linux_ext = 1;
+			vol->no_linux_ext = true;
 			break;
 		case Opt_nocase:
-			vol->nocase = 1;
+			vol->nocase = true;
 			break;
 		case Opt_brl:
-			vol->nobrl =  0;
+			vol->nobrl =  false;
 			break;
 		case Opt_nobrl:
-			vol->nobrl =  1;
+			vol->nobrl =  true;
 			/*
 			 * turn off mandatory locking in mode
 			 * if remote locking is turned off since the
@@ -1418,16 +1418,16 @@ cifs_parse_mount_options(const char *mou
 				vol->file_mode = S_IALLUGO;
 			break;
 		case Opt_forcemandatorylock:
-			vol->mand_lock = 1;
+			vol->mand_lock = true;
 			break;
 		case Opt_setuids:
-			vol->setuids = 1;
+			vol->setuids = true;
 			break;
 		case Opt_nosetuids:
-			vol->setuids = 0;
+			vol->setuids = false;
 			break;
 		case Opt_setuidfromacl:
-			vol->setuidfromacl = 1;
+			vol->setuidfromacl = true;
 			break;
 		case Opt_dynperm:
 			vol->dynperm = true;
@@ -1436,46 +1436,46 @@ cifs_parse_mount_options(const char *mou
 			vol->dynperm = false;
 			break;
 		case Opt_nohard:
-			vol->retry = 0;
+			vol->retry = false;
 			break;
 		case Opt_nosoft:
-			vol->retry = 1;
+			vol->retry = true;
 			break;
 		case Opt_nointr:
-			vol->intr = 0;
+			vol->intr = false;
 			break;
 		case Opt_intr:
-			vol->intr = 1;
+			vol->intr = true;
 			break;
 		case Opt_nostrictsync:
-			vol->nostrictsync = 1;
+			vol->nostrictsync = true;
 			break;
 		case Opt_strictsync:
-			vol->nostrictsync = 0;
+			vol->nostrictsync = false;
 			break;
 		case Opt_serverino:
-			vol->server_ino = 1;
+			vol->server_ino = true;
 			break;
 		case Opt_noserverino:
-			vol->server_ino = 0;
+			vol->server_ino = false;
 			break;
 		case Opt_rwpidforward:
-			vol->rwpidforward = 1;
+			vol->rwpidforward = true;
 			break;
 		case Opt_cifsacl:
-			vol->cifs_acl = 1;
+			vol->cifs_acl = true;
 			break;
 		case Opt_nocifsacl:
-			vol->cifs_acl = 0;
+			vol->cifs_acl = false;
 			break;
 		case Opt_acl:
-			vol->no_psx_acl = 0;
+			vol->no_psx_acl = false;
 			break;
 		case Opt_noacl:
-			vol->no_psx_acl = 1;
+			vol->no_psx_acl = true;
 			break;
 		case Opt_locallease:
-			vol->local_lease = 1;
+			vol->local_lease = true;
 			break;
 		case Opt_sign:
 			vol->sign = true;
@@ -1486,7 +1486,7 @@ cifs_parse_mount_options(const char *mou
 			 * or per-smb connection option in the protocol
 			 * vol->secFlg |= CIFSSEC_MUST_SEAL;
 			 */
-			vol->seal = 1;
+			vol->seal = true;
 			break;
 		case Opt_noac:
 			pr_warn("CIFS: Mount option noac not supported. Instead set /proc/fs/cifs/LookupCacheEnabled to 0\n");
@@ -1664,7 +1664,7 @@ cifs_parse_mount_options(const char *mou
 
 		case Opt_blank_user:
 			/* null user, ie. anonymous authentication */
-			vol->nullauth = 1;
+			vol->nullauth = true;
 			vol->username = NULL;
 			break;
 		case Opt_user:
@@ -1986,7 +1986,7 @@ cifs_parse_mount_options(const char *mou
 	else if (override_gid == 1)
 		pr_notice("CIFS: ignoring forcegid mount option specified with no gid= option.\n");
 
-	if (got_version == false)
+	if (!got_version)
 		pr_warn("No dialect specified on mount. Default has changed to "
 			"a more secure dialect, SMB3 (vers=3.0), from CIFS "
 			"(SMB1). To use the less secure SMB1 dialect to access "
@@ -2800,7 +2800,7 @@ cifs_get_tcon(struct cifs_ses *ses, stru
 		}
 	} else if ((tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
 	     && (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
-	     && (volume_info->nopersistent == false)) {
+	     && (!volume_info->nopersistent)) {
 		cifs_dbg(FYI, "enabling persistent handles\n");
 		tcon->use_persistent = true;
 	} else if (volume_info->resilient) {
@@ -3289,13 +3289,13 @@ void reset_cifs_unix_caps(unsigned int x
 
 	if (vol_info && vol_info->no_linux_ext) {
 		tcon->fsUnixInfo.Capability = 0;
-		tcon->unix_ext = 0; /* Unix Extensions disabled */
+		tcon->unix_ext = false; /* Unix Extensions disabled */
 		cifs_dbg(FYI, "Linux protocol extensions disabled\n");
 		return;
 	} else if (vol_info)
-		tcon->unix_ext = 1; /* Unix Extensions supported */
+		tcon->unix_ext = true; /* Unix Extensions supported */
 
-	if (tcon->unix_ext == 0) {
+	if (!tcon->unix_ext) {
 		cifs_dbg(FYI, "Unix extensions disabled so not set on reconnect\n");
 		return;
 	}
@@ -3333,7 +3333,7 @@ void reset_cifs_unix_caps(unsigned int x
 					CIFS_MOUNT_POSIXACL;
 		}
 
-		if (vol_info && vol_info->posix_paths == 0)
+		if (vol_info && !vol_info->posix_paths)
 			cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
 		else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
 			cifs_dbg(FYI, "negotiate posix pathnames\n");
@@ -3740,8 +3740,8 @@ try_mount_again:
 		goto mount_fail_check;
 	}
 
-	if ((volume_info->persistent == true) && ((ses->server->capabilities &
-		SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) == 0)) {
+	if ((volume_info->persistent) && ((ses->server->capabilities &
+					   SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) == 0)) {
 		cifs_dbg(VFS, "persistent handles not supported by server\n");
 		rc = -EOPNOTSUPP;
 		goto mount_fail_check;
@@ -3770,7 +3770,7 @@ try_mount_again:
 			goto mount_fail_check;
 		}
 	} else
-		tcon->unix_ext = 0; /* server does not support them */
+		tcon->unix_ext = false; /* server does not support them */
 
 	/* do not care if a following call succeed - informational */
 	if (!tcon->ipc && server->ops->qfs_tcon)
@@ -4032,7 +4032,7 @@ CIFSTCon(const unsigned int xid, struct
 			if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') &&
 			    (bcc_ptr[2] == 'C')) {
 				cifs_dbg(FYI, "IPC connection\n");
-				tcon->ipc = 1;
+				tcon->ipc = true;
 			}
 		} else if (length == 2) {
 			if ((bcc_ptr[0] == 'A') && (bcc_ptr[1] == ':')) {
@@ -4138,7 +4138,7 @@ cifs_setup_session(const unsigned int xi
 	struct TCP_Server_Info *server = ses->server;
 
 	ses->capabilities = server->capabilities;
-	if (linuxExtEnabled == 0)
+	if (!linuxExtEnabled)
 		ses->capabilities &= (~server->vals->cap_unix);
 
 	cifs_dbg(FYI, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d\n",
diff -u -p a/fs/cifs/file.c b/fs/cifs/file.c
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -702,7 +702,7 @@ cifs_reopen_file(struct cifsFileInfo *cf
 	 * not dirty locally we could do this.
 	 */
 	rc = server->ops->open(xid, &oparms, &oplock, NULL);
-	if (rc == -ENOENT && oparms.reconnect == false) {
+	if (rc == -ENOENT && !oparms.reconnect) {
 		/* durable handle timeout is expired - open the file again */
 		rc = server->ops->open(xid, &oparms, &oplock, NULL);
 		/* indicate that we need to relock the file */
diff -u -p a/fs/cifs/inode.c b/fs/cifs/inode.c
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -804,7 +804,7 @@ cifs_get_inode_info(struct inode **inode
 	 */
 	if (*inode == NULL) {
 		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
-			if (validinum == false) {
+			if (!validinum) {
 				if (server->ops->get_srv_inum)
 					tmprc = server->ops->get_srv_inum(xid,
 						tcon, cifs_sb, full_path,
@@ -820,7 +820,7 @@ cifs_get_inode_info(struct inode **inode
 			fattr.cf_uniqueid = iunique(sb, ROOT_I);
 	} else {
 		if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&
-		    validinum == false && server->ops->get_srv_inum) {
+		    !validinum && server->ops->get_srv_inum) {
 			/*
 			 * Pass a NULL tcon to ensure we don't make a round
 			 * trip to the server. This only works for SMB2+.
diff -u -p a/fs/cifs/misc.c b/fs/cifs/misc.c
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -506,7 +506,7 @@ is_valid_oplock_break(char *buffer, stru
 void
 dump_smb(void *buf, int smb_buf_length)
 {
-	if (traceSMB == 0)
+	if (!traceSMB)
 		return;
 
 	print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_NONE, 8, 2, buf,
diff -u -p a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -376,7 +376,7 @@ smb2_calc_size(void *buf)
 	 */
 	len += le16_to_cpu(pdu->StructureSize2);
 
-	if (has_smb2_data_area[le16_to_cpu(shdr->Command)] == false)
+	if (!has_smb2_data_area[le16_to_cpu(shdr->Command)])
 		goto calc_size_exit;
 
 	smb2_get_data_area_len(&offset, &data_length, hdr);
diff -u -p a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1664,7 +1664,7 @@ static long smb3_zero_range(struct file
 
 	/* if file not oplocked can't be sure whether asking to extend size */
 	if (!CIFS_CACHE_READ(cifsi))
-		if (keep_size == false)
+		if (!keep_size)
 			return -EOPNOTSUPP;
 
 	/*
@@ -1680,7 +1680,7 @@ static long smb3_zero_range(struct file
 	 * this to zero the first part of the range then set the file size
 	 * which for a non sparse file would zero the newly extended range
 	 */
-	if (keep_size == false)
+	if (!keep_size)
 		if (i_size_read(inode) < offset + len)
 			return -EOPNOTSUPP;
 
@@ -1749,7 +1749,7 @@ static long smb3_simple_falloc(struct fi
 
 	/* if file not oplocked can't be sure whether asking to extend size */
 	if (!CIFS_CACHE_READ(cifsi))
-		if (keep_size == false)
+		if (!keep_size)
 			return -EOPNOTSUPP;
 
 	/*
@@ -1758,7 +1758,7 @@ static long smb3_simple_falloc(struct fi
 	 * then no need to do anything since file already allocated
 	 */
 	if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) {
-		if (keep_size == true)
+		if (keep_size)
 			return 0;
 		/* check if extending file */
 		else if (i_size_read(inode) >= off + len)
@@ -1769,7 +1769,7 @@ static long smb3_simple_falloc(struct fi
 			return -EOPNOTSUPP;
 	}
 
-	if ((keep_size == true) || (i_size_read(inode) >= off + len)) {
+	if ((keep_size) || (i_size_read(inode) >= off + len)) {
 		/*
 		 * Check if falloc starts within first few pages of file
 		 * and ends within a few pages of the end of file to
diff -u -p a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -617,7 +617,7 @@ int smb3_validate_negotiate(const unsign
 	 * would also enable signing on the mount. Having validation of
 	 * negotiate info for signed connections helps reduce attack vectors
 	 */
-	if (tcon->ses->server->sign == false)
+	if (!tcon->ses->server->sign)
 		return 0; /* validation requires signing */
 
 	vneg_inbuf.Capabilities =

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] selinux: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (14 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] btrfs: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-10 23:17   ` Casey Schaufler
  2017-10-10 23:19   ` Casey Schaufler
  2017-10-07 14:02 ` [PATCH] configfs: " Thomas Meyer
  2017-10-10 15:19 ` [PATCH] afs: " David Howells
  17 siblings, 2 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: paul, sds, eparis, james.l.morris, serge, selinux,
	linux-security-module, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c
--- a/security/selinux/ss/mls.c
+++ b/security/selinux/ss/mls.c
@@ -550,7 +550,7 @@ int mls_compute_sid(struct context *scon
 
 		/* Fallthrough */
 	case AVTAB_CHANGE:
-		if ((tclass == policydb.process_class) || (sock == true))
+		if ((tclass == policydb.process_class) || (sock))
 			/* Use the process MLS attributes. */
 			return mls_context_cpy(newcontext, scontext);
 		else
diff -u -p a/security/selinux/ss/services.c b/security/selinux/ss/services.c
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -1656,7 +1656,7 @@ static int security_compute_sid(u32 ssid
 	} else if (cladatum && cladatum->default_role == DEFAULT_TARGET) {
 		newcontext.role = tcontext->role;
 	} else {
-		if ((tclass == policydb.process_class) || (sock == true))
+		if ((tclass == policydb.process_class) || (sock))
 			newcontext.role = scontext->role;
 		else
 			newcontext.role = OBJECT_R_VAL;
@@ -1668,7 +1668,7 @@ static int security_compute_sid(u32 ssid
 	} else if (cladatum && cladatum->default_type == DEFAULT_TARGET) {
 		newcontext.type = tcontext->type;
 	} else {
-		if ((tclass == policydb.process_class) || (sock == true)) {
+		if ((tclass == policydb.process_class) || (sock)) {
 			/* Use the type of process. */
 			newcontext.type = scontext->type;
 		} else {

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] NFS: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (3 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] nfsd: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:02 ` [PATCH] pstore: " Thomas Meyer
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: trond.myklebust, anna.schumaker, linux-nfs, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -439,7 +439,7 @@ static bool referring_call_exists(struct
 				  uint32_t nrclists,
 				  struct referring_call_list *rclists)
 {
-	bool status = 0;
+	bool status = false;
 	int i, j;
 	struct nfs4_session *session;
 	struct nfs4_slot_table *tbl;
diff -u -p a/fs/nfs/dir.c b/fs/nfs/dir.c
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -253,7 +253,7 @@ int nfs_readdir_search_for_pos(struct nf
 	desc->cache_entry_index = index;
 	return 0;
 out_eof:
-	desc->eof = 1;
+	desc->eof = true;
 	return -EBADCOOKIE;
 }
 
@@ -307,7 +307,7 @@ int nfs_readdir_search_for_cookie(struct
 	if (array->eof_index >= 0) {
 		status = -EBADCOOKIE;
 		if (*desc->dir_cookie == array->last_cookie)
-			desc->eof = 1;
+			desc->eof = true;
 	}
 out:
 	return status;
@@ -761,7 +761,7 @@ int nfs_do_filldir(nfs_readdir_descripto
 		ent = &array->array[i];
 		if (!dir_emit(desc->ctx, ent->string.name, ent->string.len,
 		    nfs_compat_user_ino64(ent->ino), ent->d_type)) {
-			desc->eof = 1;
+			desc->eof = true;
 			break;
 		}
 		desc->ctx->pos++;
@@ -773,7 +773,7 @@ int nfs_do_filldir(nfs_readdir_descripto
 			ctx->duped = 1;
 	}
 	if (array->eof_index >= 0)
-		desc->eof = 1;
+		desc->eof = true;
 
 	kunmap(desc->page);
 	cache_page_release(desc);
@@ -873,7 +873,7 @@ static int nfs_readdir(struct file *file
 		if (res == -EBADCOOKIE) {
 			res = 0;
 			/* This means either end of directory */
-			if (*desc->dir_cookie && desc->eof == 0) {
+			if (*desc->dir_cookie && !desc->eof) {
 				/* Or that the server has 'lost' a cookie */
 				res = uncached_readdir(desc);
 				if (res == 0)
diff -u -p a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -793,7 +793,7 @@ nfs4_find_client_sessionid(struct net *n
 
 	spin_lock(&nn->nfs_client_lock);
 	list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
-		if (nfs4_cb_match_client(addr, clp, minorversion) == false)
+		if (!nfs4_cb_match_client(addr, clp, minorversion))
 			continue;
 
 		if (!nfs4_has_session(clp))
diff -u -p a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1513,7 +1513,7 @@ pnfs_lseg_range_match(const struct pnfs_
 	if ((range->iomode == IOMODE_RW &&
 	     ls_range->iomode != IOMODE_RW) ||
 	    (range->iomode != ls_range->iomode &&
-	     strict_iomode == true) ||
+	     strict_iomode) ||
 	    !pnfs_lseg_range_intersecting(ls_range, range))
 		return 0;
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] bfq: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (8 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] ceph: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:02 ` [PATCH] proc: " Thomas Meyer
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: paolo.valente, axboe, linux-block, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/block/bfq-iosched.c b/block/bfq-iosched.c
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -4986,7 +4986,7 @@ static ssize_t bfq_low_latency_store(str
 
 	if (__data > 1)
 		__data = 1;
-	if (__data == 0 && bfqd->low_latency != 0)
+	if (__data == 0 && bfqd->low_latency)
 		bfq_end_wr(bfqd);
 	bfqd->low_latency = __data;
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] xfs: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (6 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] afs: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-09 14:24   ` Brian Foster
  2017-10-07 14:02 ` [PATCH] ceph: " Thomas Meyer
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: darrick.wong, linux-xfs, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1490,14 +1490,14 @@ xfs_bmap_isaeof(
 	int			is_empty;
 	int			error;
 
-	bma->aeof = 0;
+	bma->aeof = false;
 	error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec,
 				     &is_empty);
 	if (error)
 		return error;
 
 	if (is_empty) {
-		bma->aeof = 1;
+		bma->aeof = true;
 		return 0;
 	}
 
diff -u -p a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -1962,7 +1962,7 @@ xfs_difree_inobt(
 	if (!(mp->m_flags & XFS_MOUNT_IKEEP) &&
 	    rec.ir_free == XFS_INOBT_ALL_FREE &&
 	    mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) {
-		xic->deleted = 1;
+		xic->deleted = true;
 		xic->first_ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino);
 		xic->alloc = xfs_inobt_irec_to_allocmask(&rec);
 
@@ -1989,7 +1989,7 @@ xfs_difree_inobt(
 
 		xfs_difree_inode_chunk(mp, agno, &rec, dfops);
 	} else {
-		xic->deleted = 0;
+		xic->deleted = false;
 
 		error = xfs_inobt_update(cur, &rec);
 		if (error) {
diff -u -p a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -761,7 +761,7 @@ xfs_file_fallocate(
 	enum xfs_prealloc_flags	flags = 0;
 	uint			iolock = XFS_IOLOCK_EXCL;
 	loff_t			new_size = 0;
-	bool			do_file_insert = 0;
+	bool			do_file_insert = false;
 
 	if (!S_ISREG(inode->i_mode))
 		return -EINVAL;
@@ -822,7 +822,7 @@ xfs_file_fallocate(
 			error = -EINVAL;
 			goto out_unlock;
 		}
-		do_file_insert = 1;
+		do_file_insert = true;
 	} else {
 		flags |= XFS_PREALLOC_SET;
 
diff -u -p a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2515,7 +2515,7 @@ next_lv:
 				if (lv)
 					vecp = lv->lv_iovecp;
 			}
-			if (record_cnt == 0 && ordered == false) {
+			if (record_cnt == 0 && !ordered) {
 				if (!lv)
 					return 0;
 				break;
diff -u -p a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -704,7 +704,7 @@ xfs_mountfs(
 	xfs_set_maxicount(mp);
 
 	/* enable fail_at_unmount as default */
-	mp->m_fail_unmount = 1;
+	mp->m_fail_unmount = true;
 
 	error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname);
 	if (error)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] proc: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (9 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] bfq: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:02 ` [PATCH] exofs: " Thomas Meyer
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/proc/generic.c b/fs/proc/generic.c
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -325,7 +325,7 @@ static int proc_register(struct proc_dir
 
 	write_lock(&proc_subdir_lock);
 	dp->parent = dir;
-	if (pde_subdir_insert(dir, dp) == false) {
+	if (!pde_subdir_insert(dir, dp)) {
 		WARN(1, "proc_dir_entry '%s/%s' already registered\n",
 		     dir->name, dp->name);
 		write_unlock(&proc_subdir_lock);

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] f2fs: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:33   ` [f2fs-dev] " Ju Hyung Park
  2017-10-07 14:02 ` [PATCH] cifs: " Thomas Meyer
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/f2fs/data.c b/fs/f2fs/data.c
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -419,7 +419,7 @@ next:
 	bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
 
 	/* set submitted = 1 as a return value */
-	fio->submitted = 1;
+	fio->submitted = true;
 
 	inc_page_count(sbi, WB_DATA_TYPE(bio_page));
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] nfsd: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (2 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] ima: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:02 ` [PATCH] NFS: " Thomas Meyer
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: bfields, jlayton, linux-nfs, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -230,7 +230,7 @@ do_open_lookup(struct svc_rqst *rqstp, s
 	if (!*resfh)
 		return nfserr_jukebox;
 	fh_init(*resfh, NFS4_FHSIZE);
-	open->op_truncate = 0;
+	open->op_truncate = false;
 
 	if (open->op_create) {
 		/* FIXME: check session persistence and pnfs flags.
@@ -360,7 +360,7 @@ nfsd4_open(struct svc_rqst *rqstp, struc
 	if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
 		return nfserr_inval;
 
-	open->op_created = 0;
+	open->op_created = false;
 	/*
 	 * RFC5661 18.51.3
 	 * Before RECLAIM_COMPLETE done, server should deny new lock
@@ -1108,8 +1108,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struc
 	else {
 		copy->cp_res.wr_bytes_written = bytes;
 		copy->cp_res.wr_stable_how = NFS_UNSTABLE;
-		copy->cp_consecutive = 1;
-		copy->cp_synchronous = 1;
+		copy->cp_consecutive = true;
+		copy->cp_synchronous = true;
 		gen_boot_verifier(&copy->cp_res.wr_verifier, SVC_NET(rqstp));
 		status = nfs_ok;
 	}
@@ -2476,7 +2476,7 @@ bool nfsd4_spo_must_allow(struct svc_rqs
 	if (!cstate->minorversion)
 		return false;
 
-	if (cstate->spo_must_allowed == true)
+	if (cstate->spo_must_allowed)
 		return true;
 
 	opiter = resp->opcnt;
diff -u -p a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -292,7 +292,7 @@ static int nfsd_startup_net(int nrservs,
 		ret = lockd_up(net);
 		if (ret)
 			goto out_socks;
-		nn->lockd_up = 1;
+		nn->lockd_up = true;
 	}
 
 	ret = nfs4_state_start_net(net);
@@ -305,7 +305,7 @@ static int nfsd_startup_net(int nrservs,
 out_lockd:
 	if (nn->lockd_up) {
 		lockd_down(net);
-		nn->lockd_up = 0;
+		nn->lockd_up = false;
 	}
 out_socks:
 	nfsd_shutdown_generic();
@@ -319,7 +319,7 @@ static void nfsd_shutdown_net(struct net
 	nfs4_state_shutdown_net(net);
 	if (nn->lockd_up) {
 		lockd_down(net);
-		nn->lockd_up = 0;
+		nn->lockd_up = false;
 	}
 	nn->nfsd_net_up = false;
 	nfsd_shutdown_generic();
diff -u -p a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1379,7 +1379,7 @@ do_nfsd_create(struct svc_rqst *rqstp, s
 			    && d_inode(dchild)->i_atime.tv_sec == v_atime
 			    && d_inode(dchild)->i_size  == 0 ) {
 				if (created)
-					*created = 1;
+					*created = true;
 				break;
 			}
 		case NFS4_CREATE_EXCLUSIVE4_1:
@@ -1387,7 +1387,7 @@ do_nfsd_create(struct svc_rqst *rqstp, s
 			    && d_inode(dchild)->i_atime.tv_sec == v_atime
 			    && d_inode(dchild)->i_size  == 0 ) {
 				if (created)
-					*created = 1;
+					*created = true;
 				goto set_attr;
 			}
 			 /* fallthru */
@@ -1404,7 +1404,7 @@ do_nfsd_create(struct svc_rqst *rqstp, s
 		goto out_nfserr;
 	}
 	if (created)
-		*created = 1;
+		*created = true;
 
 	nfsd_check_ignore_resizing(iap);
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] ima: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
  2017-10-07 14:02 ` [PATCH] f2fs: Fix bool initialization/comparison Thomas Meyer
  2017-10-07 14:02 ` [PATCH] cifs: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:02 ` [PATCH] nfsd: " Thomas Meyer
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, james.l.morris, serge, linux-ima-devel,
	linux-ima-user, linux-security-module, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -32,7 +32,7 @@ bool ima_canonical_fmt;
 static int __init default_canonical_fmt_setup(char *str)
 {
 #ifdef __BIG_ENDIAN
-	ima_canonical_fmt = 1;
+	ima_canonical_fmt = true;
 #endif
 	return 1;
 }
diff -u -p a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -196,9 +196,9 @@ static int __init policy_setup(char *str
 		if ((strcmp(p, "tcb") == 0) && !ima_policy)
 			ima_policy = DEFAULT_TCB;
 		else if (strcmp(p, "appraise_tcb") == 0)
-			ima_use_appraise_tcb = 1;
+			ima_use_appraise_tcb = true;
 		else if (strcmp(p, "secure_boot") == 0)
-			ima_use_secure_boot = 1;
+			ima_use_secure_boot = true;
 	}
 
 	return 1;
@@ -207,7 +207,7 @@ __setup("ima_policy=", policy_setup);
 
 static int __init default_appraise_policy_setup(char *str)
 {
-	ima_use_appraise_tcb = 1;
+	ima_use_appraise_tcb = true;
 	return 1;
 }
 __setup("ima_appraise_tcb", default_appraise_policy_setup);

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] configfs: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (15 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] selinux: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-19 14:08   ` Christoph Hellwig
  2017-10-10 15:19 ` [PATCH] afs: " David Howells
  17 siblings, 1 reply; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: jlbec, hch, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/configfs/file.c b/fs/configfs/file.c
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -166,7 +166,7 @@ configfs_read_bin_file(struct file *file
 		retval = -ETXTBSY;
 		goto out;
 	}
-	buffer->read_in_progress = 1;
+	buffer->read_in_progress = true;
 
 	if (buffer->needs_read_fill) {
 		/* perform first read with buf == NULL to get extent */
@@ -325,7 +325,7 @@ configfs_write_bin_file(struct file *fil
 		len = -ETXTBSY;
 		goto out;
 	}
-	buffer->write_in_progress = 1;
+	buffer->write_in_progress = true;
 
 	/* buffer grows? */
 	if (*ppos + count > buffer->bin_buffer_size) {
@@ -429,8 +429,8 @@ static int check_perm(struct inode * ino
 	}
 	mutex_init(&buffer->mutex);
 	buffer->needs_read_fill = 1;
-	buffer->read_in_progress = 0;
-	buffer->write_in_progress = 0;
+	buffer->read_in_progress = false;
+	buffer->write_in_progress = false;
 	buffer->ops = ops;
 	file->private_data = buffer;
 	goto Done;
@@ -488,10 +488,10 @@ static int configfs_release_bin_file(str
 	ssize_t len = 0;
 	int ret;
 
-	buffer->read_in_progress = 0;
+	buffer->read_in_progress = false;
 
 	if (buffer->write_in_progress) {
-		buffer->write_in_progress = 0;
+		buffer->write_in_progress = false;
 
 		len = bin_attr->write(item, buffer->bin_buffer,
 				buffer->bin_buffer_size);

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] pstore: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (4 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] NFS: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2018-11-29 23:21   ` Kees Cook
  2017-10-07 14:02 ` [PATCH] afs: " Thomas Meyer
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c
--- a/fs/pstore/ftrace.c
+++ b/fs/pstore/ftrace.c
@@ -148,7 +148,7 @@ void pstore_unregister_ftrace(void)
 	mutex_lock(&pstore_ftrace_lock);
 	if (pstore_ftrace_enabled) {
 		unregister_ftrace_function(&pstore_ftrace_ops);
-		pstore_ftrace_enabled = 0;
+		pstore_ftrace_enabled = false;
 	}
 	mutex_unlock(&pstore_ftrace_lock);
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Cocci spatch "boolinit" - v4.14-rc1
@ 2017-10-07 14:02 Thomas Meyer
  2017-10-07 14:02 ` [PATCH] f2fs: Fix bool initialization/comparison Thomas Meyer
                   ` (17 more replies)
  0 siblings, 18 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Found by coccinelle spatch "misc/boolinit.cocci"

Run against version v4.14-rc1

P.S. If you find this email unwanted, set up a procmail rule junking on
the header:

X-Patch: Cocci

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] exofs: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (10 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] proc: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 14:02 ` [PATCH] apparmor: " Thomas Meyer
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: ooo, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/exofs/super.c b/fs/exofs/super.c
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -116,7 +116,7 @@ static int parse_options(char *options,
 					  EXOFS_MIN_PID);
 				return -EINVAL;
 			}
-			s_pid = 1;
+			s_pid = true;
 			break;
 		case Opt_to:
 			if (match_int(&args[0], &option))

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] btrfs: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (13 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] ext4: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-09 16:05   ` David Sterba
  2017-10-07 14:02 ` [PATCH] selinux: " Thomas Meyer
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: clm, jbacik, dsterba, linux-btrfs, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6958,7 +6958,7 @@ static int __btrfs_free_extent(struct bt
 	BUG_ON(!is_data && refs_to_drop != 1);
 
 	if (is_data)
-		skinny_metadata = 0;
+		skinny_metadata = false;
 
 	ret = lookup_extent_backref(trans, info, path, &iref,
 				    bytenr, num_bytes, parent,
@@ -9311,7 +9311,7 @@ out:
 	 * don't have it in the radix (like when we recover after a power fail
 	 * or unmount) so we don't leak memory.
 	 */
-	if (!for_reloc && root_dropped == false)
+	if (!for_reloc && !root_dropped)
 		btrfs_add_dead_root(root);
 	if (err && err != -EAGAIN)
 		btrfs_handle_fs_error(fs_info, err, NULL);
diff -u -p a/fs/btrfs/file.c b/fs/btrfs/file.c
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2046,7 +2046,7 @@ int btrfs_sync_file(struct file *file, l
 	struct btrfs_trans_handle *trans;
 	struct btrfs_log_ctx ctx;
 	int ret = 0, err;
-	bool full_sync = 0;
+	bool full_sync = false;
 	u64 len;
 
 	/*
diff -u -p a/fs/btrfs/inode.c b/fs/btrfs/inode.c
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4439,9 +4439,9 @@ int btrfs_truncate_inode_items(struct bt
 	int err = 0;
 	u64 ino = btrfs_ino(BTRFS_I(inode));
 	u64 bytes_deleted = 0;
-	bool be_nice = 0;
-	bool should_throttle = 0;
-	bool should_end = 0;
+	bool be_nice = false;
+	bool should_throttle = false;
+	bool should_end = false;
 
 	BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY);
 
@@ -4451,7 +4451,7 @@ int btrfs_truncate_inode_items(struct bt
 	 */
 	if (!btrfs_is_free_space_inode(BTRFS_I(inode)) &&
 	    test_bit(BTRFS_ROOT_REF_COWS, &root->state))
-		be_nice = 1;
+		be_nice = true;
 
 	path = btrfs_alloc_path();
 	if (!path)
@@ -4657,7 +4657,7 @@ delete:
 		} else {
 			break;
 		}
-		should_throttle = 0;
+		should_throttle = false;
 
 		if (found_extent &&
 		    (test_bit(BTRFS_ROOT_REF_COWS, &root->state) ||
@@ -4676,11 +4676,11 @@ delete:
 			if (be_nice) {
 				if (truncate_space_check(trans, root,
 							 extent_num_bytes)) {
-					should_end = 1;
+					should_end = true;
 				}
 				if (btrfs_should_throttle_delayed_refs(trans,
 								       fs_info))
-					should_throttle = 1;
+					should_throttle = true;
 			}
 		}
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] apparmor: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (11 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] exofs: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-07 17:18   ` John Johansen
  2017-10-07 14:02 ` [PATCH] ext4: " Thomas Meyer
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: john.johansen, james.l.morris, serge, linux-security-module,
	linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/security/apparmor/lsm.c b/security/apparmor/lsm.c
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -761,7 +761,7 @@ module_param_call(audit, param_set_audit
 /* Determines if audit header is included in audited messages.  This
  * provides more context if the audit daemon is not running
  */
-bool aa_g_audit_header = 1;
+bool aa_g_audit_header = true;
 module_param_named(audit_header, aa_g_audit_header, aabool,
 		   S_IRUSR | S_IWUSR);
 
@@ -786,7 +786,7 @@ module_param_named(path_max, aa_g_path_m
  * DEPRECATED: read only as strict checking of load is always done now
  * that none root users (user namespaces) can load policy.
  */
-bool aa_g_paranoid_load = 1;
+bool aa_g_paranoid_load = true;
 module_param_named(paranoid_load, aa_g_paranoid_load, aabool, S_IRUGO);
 
 /* Boot time disable flag */
@@ -1034,7 +1034,7 @@ static int __init apparmor_init(void)
 
 	if (!apparmor_enabled || !security_module_enable("apparmor")) {
 		aa_info_message("AppArmor disabled by boot time parameter");
-		apparmor_enabled = 0;
+		apparmor_enabled = false;
 		return 0;
 	}
 
@@ -1090,7 +1090,7 @@ alloc_out:
 	aa_destroy_aafs();
 	aa_teardown_dfa_engine();
 
-	apparmor_enabled = 0;
+	apparmor_enabled = false;
 	return error;
 }
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH] ceph: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (7 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] xfs: " Thomas Meyer
@ 2017-10-07 14:02 ` Thomas Meyer
  2017-10-09  1:52   ` Yan, Zheng
  2017-10-07 14:02 ` [PATCH] bfq: " Thomas Meyer
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Thomas Meyer @ 2017-10-07 14:02 UTC (permalink / raw)
  To: zyan, sage, idryomov, ceph-devel, linux-kernel

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/fs/ceph/caps.c b/fs/ceph/caps.c
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1711,7 +1711,7 @@ void ceph_check_caps(struct ceph_inode_i
 
 	/* if we are unmounting, flush any unused caps immediately. */
 	if (mdsc->stopping)
-		is_delayed = 1;
+		is_delayed = true;
 
 	spin_lock(&ci->i_ceph_lock);
 
@@ -3185,8 +3185,8 @@ static void handle_cap_flush_ack(struct
 	int dirty = le32_to_cpu(m->dirty);
 	int cleaned = 0;
 	bool drop = false;
-	bool wake_ci = 0;
-	bool wake_mdsc = 0;
+	bool wake_ci = false;
+	bool wake_mdsc = false;
 
 	list_for_each_entry_safe(cf, tmp_cf, &ci->i_cap_flush_list, i_list) {
 		if (cf->tid == flush_tid)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] f2fs: Fix bool initialization/comparison Thomas Meyer
@ 2017-10-07 14:33   ` Ju Hyung Park
  2017-10-07 19:30     ` Joe Perches
  0 siblings, 1 reply; 33+ messages in thread
From: Ju Hyung Park @ 2017-10-07 14:33 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: jaegeuk, Chao Yu, linux-f2fs-devel, linux-kernel

Isn't this bogus?

"bool" type in Linux kernel is a typedef to "_Bool"
and true/false is defined as 1 and 0 by enum at include/linux/stddef.h.

On Sat, Oct 7, 2017 at 11:02 PM, Thomas Meyer <thomas@m3y3r.de> wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
>
> diff -u -p a/fs/f2fs/data.c b/fs/f2fs/data.c
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -419,7 +419,7 @@ next:
>         bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
>
>         /* set submitted = 1 as a return value */
> -       fio->submitted = 1;
> +       fio->submitted = true;
>
>         inc_page_count(sbi, WB_DATA_TYPE(bio_page));
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] apparmor: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] apparmor: " Thomas Meyer
@ 2017-10-07 17:18   ` John Johansen
  0 siblings, 0 replies; 33+ messages in thread
From: John Johansen @ 2017-10-07 17:18 UTC (permalink / raw)
  To: Thomas Meyer, james.l.morris, serge, linux-security-module, linux-kernel

On 10/07/2017 07:02 AM, Thomas Meyer wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Acked-by: John Johansen <john.johansen@canonical.com>

I have pulled this into apparmor-next

> ---
> 
> diff -u -p a/security/apparmor/lsm.c b/security/apparmor/lsm.c
> --- a/security/apparmor/lsm.c
> +++ b/security/apparmor/lsm.c
> @@ -761,7 +761,7 @@ module_param_call(audit, param_set_audit
>  /* Determines if audit header is included in audited messages.  This
>   * provides more context if the audit daemon is not running
>   */
> -bool aa_g_audit_header = 1;
> +bool aa_g_audit_header = true;
>  module_param_named(audit_header, aa_g_audit_header, aabool,
>  		   S_IRUSR | S_IWUSR);
>  
> @@ -786,7 +786,7 @@ module_param_named(path_max, aa_g_path_m
>   * DEPRECATED: read only as strict checking of load is always done now
>   * that none root users (user namespaces) can load policy.
>   */
> -bool aa_g_paranoid_load = 1;
> +bool aa_g_paranoid_load = true;
>  module_param_named(paranoid_load, aa_g_paranoid_load, aabool, S_IRUGO);
>  
>  /* Boot time disable flag */
> @@ -1034,7 +1034,7 @@ static int __init apparmor_init(void)
>  
>  	if (!apparmor_enabled || !security_module_enable("apparmor")) {
>  		aa_info_message("AppArmor disabled by boot time parameter");
> -		apparmor_enabled = 0;
> +		apparmor_enabled = false;
>  		return 0;
>  	}
>  
> @@ -1090,7 +1090,7 @@ alloc_out:
>  	aa_destroy_aafs();
>  	aa_teardown_dfa_engine();
>  
> -	apparmor_enabled = 0;
> +	apparmor_enabled = false;
>  	return error;
>  }
>  
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: Fix bool initialization/comparison
  2017-10-07 14:33   ` [f2fs-dev] " Ju Hyung Park
@ 2017-10-07 19:30     ` Joe Perches
  2017-10-09  1:48       ` Chao Yu
  0 siblings, 1 reply; 33+ messages in thread
From: Joe Perches @ 2017-10-07 19:30 UTC (permalink / raw)
  To: Ju Hyung Park, Thomas Meyer
  Cc: jaegeuk, Chao Yu, linux-f2fs-devel, linux-kernel

On Sat, 2017-10-07 at 23:33 +0900, Ju Hyung Park wrote:
> Isn't this bogus?
> 
> "bool" type in Linux kernel is a typedef to "_Bool"
> and true/false is defined as 1 and 0 by enum at include/linux/stddef.h.

Bogus?  Well, not really.  It's just a neatening and it's
identical object code.

The idea is that true/false is more intelligible than 1/0
for a human reader.

> On Sat, Oct 7, 2017 at 11:02 PM, Thomas Meyer <thomas@m3y3r.de> wrote:
> > Bool initializations should use true and false. Bool tests don't need
> > comparisons.
[]
> > diff -u -p a/fs/f2fs/data.c b/fs/f2fs/data.c
[]
> > @@ -419,7 +419,7 @@ next:
> >         bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
> > 
> >         /* set submitted = 1 as a return value */
> > -       fio->submitted = 1;
> > +       fio->submitted = true;
> > 
> >         inc_page_count(sbi, WB_DATA_TYPE(bio_page));
> > 

And it's probably better to change the comment too.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: Fix bool initialization/comparison
  2017-10-07 19:30     ` Joe Perches
@ 2017-10-09  1:48       ` Chao Yu
  2017-10-10 17:41         ` Jaegeuk Kim
  0 siblings, 1 reply; 33+ messages in thread
From: Chao Yu @ 2017-10-09  1:48 UTC (permalink / raw)
  To: Joe Perches, Ju Hyung Park, Thomas Meyer
  Cc: jaegeuk, linux-f2fs-devel, linux-kernel

On 2017/10/8 3:30, Joe Perches wrote:
> On Sat, 2017-10-07 at 23:33 +0900, Ju Hyung Park wrote:
>> Isn't this bogus?
>>
>> "bool" type in Linux kernel is a typedef to "_Bool"
>> and true/false is defined as 1 and 0 by enum at include/linux/stddef.h.
> 
> Bogus?  Well, not really.  It's just a neatening and it's
> identical object code.
> 
> The idea is that true/false is more intelligible than 1/0
> for a human reader.

Yes, that's just cleanup.

Hi Thomas, could you change the commit message a bit?

> 
>> On Sat, Oct 7, 2017 at 11:02 PM, Thomas Meyer <thomas@m3y3r.de> wrote:
>>> Bool initializations should use true and false. Bool tests don't need
>>> comparisons.
> []
>>> diff -u -p a/fs/f2fs/data.c b/fs/f2fs/data.c
> []
>>> @@ -419,7 +419,7 @@ next:
>>>         bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
>>>
>>>         /* set submitted = 1 as a return value */

Comment should be updated too.

Thanks,

>>> -       fio->submitted = 1;
>>> +       fio->submitted = true;
>>>
>>>         inc_page_count(sbi, WB_DATA_TYPE(bio_page));
>>>
> 
> And it's probably better to change the comment too.
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] ceph: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] ceph: " Thomas Meyer
@ 2017-10-09  1:52   ` Yan, Zheng
  0 siblings, 0 replies; 33+ messages in thread
From: Yan, Zheng @ 2017-10-09  1:52 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: Sage Weil, idryomov, ceph-devel, linux-kernel



> On 7 Oct 2017, at 22:02, Thomas Meyer <thomas@m3y3r.de> wrote:
> 
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
> 
> diff -u -p a/fs/ceph/caps.c b/fs/ceph/caps.c
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -1711,7 +1711,7 @@ void ceph_check_caps(struct ceph_inode_i
> 
> 	/* if we are unmounting, flush any unused caps immediately. */
> 	if (mdsc->stopping)
> -		is_delayed = 1;
> +		is_delayed = true;
> 
> 	spin_lock(&ci->i_ceph_lock);
> 
> @@ -3185,8 +3185,8 @@ static void handle_cap_flush_ack(struct
> 	int dirty = le32_to_cpu(m->dirty);
> 	int cleaned = 0;
> 	bool drop = false;
> -	bool wake_ci = 0;
> -	bool wake_mdsc = 0;
> +	bool wake_ci = false;
> +	bool wake_mdsc = false;
> 
> 	list_for_each_entry_safe(cf, tmp_cf, &ci->i_cap_flush_list, i_list) {
> 		if (cf->tid == flush_tid)

Applied, thanks

Yan, Zheng

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] xfs: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] xfs: " Thomas Meyer
@ 2017-10-09 14:24   ` Brian Foster
  0 siblings, 0 replies; 33+ messages in thread
From: Brian Foster @ 2017-10-09 14:24 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: darrick.wong, linux-xfs, linux-kernel

On Sat, Oct 07, 2017 at 04:02:21PM +0200, Thomas Meyer wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

> 
> diff -u -p a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1490,14 +1490,14 @@ xfs_bmap_isaeof(
>  	int			is_empty;
>  	int			error;
>  
> -	bma->aeof = 0;
> +	bma->aeof = false;
>  	error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec,
>  				     &is_empty);
>  	if (error)
>  		return error;
>  
>  	if (is_empty) {
> -		bma->aeof = 1;
> +		bma->aeof = true;
>  		return 0;
>  	}
>  
> diff -u -p a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -1962,7 +1962,7 @@ xfs_difree_inobt(
>  	if (!(mp->m_flags & XFS_MOUNT_IKEEP) &&
>  	    rec.ir_free == XFS_INOBT_ALL_FREE &&
>  	    mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) {
> -		xic->deleted = 1;
> +		xic->deleted = true;
>  		xic->first_ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino);
>  		xic->alloc = xfs_inobt_irec_to_allocmask(&rec);
>  
> @@ -1989,7 +1989,7 @@ xfs_difree_inobt(
>  
>  		xfs_difree_inode_chunk(mp, agno, &rec, dfops);
>  	} else {
> -		xic->deleted = 0;
> +		xic->deleted = false;
>  
>  		error = xfs_inobt_update(cur, &rec);
>  		if (error) {
> diff -u -p a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -761,7 +761,7 @@ xfs_file_fallocate(
>  	enum xfs_prealloc_flags	flags = 0;
>  	uint			iolock = XFS_IOLOCK_EXCL;
>  	loff_t			new_size = 0;
> -	bool			do_file_insert = 0;
> +	bool			do_file_insert = false;
>  
>  	if (!S_ISREG(inode->i_mode))
>  		return -EINVAL;
> @@ -822,7 +822,7 @@ xfs_file_fallocate(
>  			error = -EINVAL;
>  			goto out_unlock;
>  		}
> -		do_file_insert = 1;
> +		do_file_insert = true;
>  	} else {
>  		flags |= XFS_PREALLOC_SET;
>  
> diff -u -p a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -2515,7 +2515,7 @@ next_lv:
>  				if (lv)
>  					vecp = lv->lv_iovecp;
>  			}
> -			if (record_cnt == 0 && ordered == false) {
> +			if (record_cnt == 0 && !ordered) {
>  				if (!lv)
>  					return 0;
>  				break;
> diff -u -p a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -704,7 +704,7 @@ xfs_mountfs(
>  	xfs_set_maxicount(mp);
>  
>  	/* enable fail_at_unmount as default */
> -	mp->m_fail_unmount = 1;
> +	mp->m_fail_unmount = true;
>  
>  	error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname);
>  	if (error)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] btrfs: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] btrfs: " Thomas Meyer
@ 2017-10-09 16:05   ` David Sterba
  0 siblings, 0 replies; 33+ messages in thread
From: David Sterba @ 2017-10-09 16:05 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: clm, jbacik, dsterba, linux-btrfs, linux-kernel

On Sat, Oct 07, 2017 at 04:02:21PM +0200, Thomas Meyer wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Reviewed-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] cifs: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] cifs: " Thomas Meyer
@ 2017-10-10  1:14   ` Nico Kadel-Garcia
  0 siblings, 0 replies; 33+ messages in thread
From: Nico Kadel-Garcia @ 2017-10-10  1:14 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: sfrench, linux-cifs, samba-technical, linux-kernel

On Sat, Oct 7, 2017 at 10:02 AM, Thomas Meyer via samba-technical
<samba-technical@lists.samba.org> wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.

Except that "==" is not a pure boolean check. It's a value check, and
unless these values are defined *very* carefully they may be set to
non-boolean values.

You may be write on these specific checks that they are, in fact,
booleans. But I'd be be cautious about stripping out such checks as a
matter of style.


> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
>
> diff -u -p a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
> --- a/fs/cifs/cifsacl.c
> +++ b/fs/cifs/cifsacl.c
> @@ -370,7 +370,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb,
>                 else
>                         is_group = false;
>
> -               if (is_well_known_sid(psid, &unix_id, is_group) == false)
> +               if (!is_well_known_sid(psid, &unix_id, is_group))
>                         goto try_upcall_to_get_id;
>
>                 if (is_group) {
> diff -u -p a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> --- a/fs/cifs/cifssmb.c
> +++ b/fs/cifs/cifssmb.c
> @@ -4508,7 +4508,7 @@ findFirstRetry:
>                                 psrch_inf->unicode = false;
>
>                         psrch_inf->ntwrk_buf_start = (char *)pSMBr;
> -                       psrch_inf->smallBuf = 0;
> +                       psrch_inf->smallBuf = false;
>                         psrch_inf->srch_entries_start =
>                                 (char *) &pSMBr->hdr.Protocol +
>                                         le16_to_cpu(pSMBr->t2.DataOffset);
> @@ -4642,7 +4642,7 @@ int CIFSFindNext(const unsigned int xid,
>                                 cifs_buf_release(psrch_inf->ntwrk_buf_start);
>                         psrch_inf->srch_entries_start = response_data;
>                         psrch_inf->ntwrk_buf_start = (char *)pSMB;
> -                       psrch_inf->smallBuf = 0;
> +                       psrch_inf->smallBuf = false;
>                         if (parms->EndofSearch)
>                                 psrch_inf->endOfSearch = true;
>                         else
> diff -u -p a/fs/cifs/connect.c b/fs/cifs/connect.c
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -1081,7 +1081,7 @@ static int cifs_parse_security_flavors(c
>                 break;
>  #endif
>         case Opt_sec_none:
> -               vol->nullauth = 1;
> +               vol->nullauth = true;
>                 break;
>         default:
>                 cifs_dbg(VFS, "bad security option: %s\n", value);
> @@ -1265,9 +1265,9 @@ cifs_parse_mount_options(const char *mou
>
>         /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */
>         /* default is always to request posix paths. */
> -       vol->posix_paths = 1;
> +       vol->posix_paths = true;
>         /* default to using server inode numbers where available */
> -       vol->server_ino = 1;
> +       vol->server_ino = true;
>
>         /* default is to use strict cifs caching semantics */
>         vol->strict_io = true;
> @@ -1333,10 +1333,10 @@ cifs_parse_mount_options(const char *mou
>
>                 /* Boolean values */
>                 case Opt_user_xattr:
> -                       vol->no_xattr = 0;
> +                       vol->no_xattr = false;
>                         break;
>                 case Opt_nouser_xattr:
> -                       vol->no_xattr = 1;
> +                       vol->no_xattr = true;
>                         break;
>                 case Opt_forceuid:
>                         override_uid = 1;
> @@ -1351,22 +1351,22 @@ cifs_parse_mount_options(const char *mou
>                         override_gid = 0;
>                         break;
>                 case Opt_noblocksend:
> -                       vol->noblocksnd = 1;
> +                       vol->noblocksnd = true;
>                         break;
>                 case Opt_noautotune:
> -                       vol->noautotune = 1;
> +                       vol->noautotune = true;
>                         break;
>                 case Opt_hard:
> -                       vol->retry = 1;
> +                       vol->retry = true;
>                         break;
>                 case Opt_soft:
> -                       vol->retry = 0;
> +                       vol->retry = false;
>                         break;
>                 case Opt_perm:
> -                       vol->noperm = 0;
> +                       vol->noperm = false;
>                         break;
>                 case Opt_noperm:
> -                       vol->noperm = 1;
> +                       vol->noperm = true;
>                         break;
>                 case Opt_mapchars:
>                         vol->sfu_remap = true;
> @@ -1383,31 +1383,31 @@ cifs_parse_mount_options(const char *mou
>                         vol->remap = false;
>                         break;
>                 case Opt_sfu:
> -                       vol->sfu_emul = 1;
> +                       vol->sfu_emul = true;
>                         break;
>                 case Opt_nosfu:
> -                       vol->sfu_emul = 0;
> +                       vol->sfu_emul = false;
>                         break;
>                 case Opt_nodfs:
> -                       vol->nodfs = 1;
> +                       vol->nodfs = true;
>                         break;
>                 case Opt_posixpaths:
> -                       vol->posix_paths = 1;
> +                       vol->posix_paths = true;
>                         break;
>                 case Opt_noposixpaths:
> -                       vol->posix_paths = 0;
> +                       vol->posix_paths = false;
>                         break;
>                 case Opt_nounix:
> -                       vol->no_linux_ext = 1;
> +                       vol->no_linux_ext = true;
>                         break;
>                 case Opt_nocase:
> -                       vol->nocase = 1;
> +                       vol->nocase = true;
>                         break;
>                 case Opt_brl:
> -                       vol->nobrl =  0;
> +                       vol->nobrl =  false;
>                         break;
>                 case Opt_nobrl:
> -                       vol->nobrl =  1;
> +                       vol->nobrl =  true;
>                         /*
>                          * turn off mandatory locking in mode
>                          * if remote locking is turned off since the
> @@ -1418,16 +1418,16 @@ cifs_parse_mount_options(const char *mou
>                                 vol->file_mode = S_IALLUGO;
>                         break;
>                 case Opt_forcemandatorylock:
> -                       vol->mand_lock = 1;
> +                       vol->mand_lock = true;
>                         break;
>                 case Opt_setuids:
> -                       vol->setuids = 1;
> +                       vol->setuids = true;
>                         break;
>                 case Opt_nosetuids:
> -                       vol->setuids = 0;
> +                       vol->setuids = false;
>                         break;
>                 case Opt_setuidfromacl:
> -                       vol->setuidfromacl = 1;
> +                       vol->setuidfromacl = true;
>                         break;
>                 case Opt_dynperm:
>                         vol->dynperm = true;
> @@ -1436,46 +1436,46 @@ cifs_parse_mount_options(const char *mou
>                         vol->dynperm = false;
>                         break;
>                 case Opt_nohard:
> -                       vol->retry = 0;
> +                       vol->retry = false;
>                         break;
>                 case Opt_nosoft:
> -                       vol->retry = 1;
> +                       vol->retry = true;
>                         break;
>                 case Opt_nointr:
> -                       vol->intr = 0;
> +                       vol->intr = false;
>                         break;
>                 case Opt_intr:
> -                       vol->intr = 1;
> +                       vol->intr = true;
>                         break;
>                 case Opt_nostrictsync:
> -                       vol->nostrictsync = 1;
> +                       vol->nostrictsync = true;
>                         break;
>                 case Opt_strictsync:
> -                       vol->nostrictsync = 0;
> +                       vol->nostrictsync = false;
>                         break;
>                 case Opt_serverino:
> -                       vol->server_ino = 1;
> +                       vol->server_ino = true;
>                         break;
>                 case Opt_noserverino:
> -                       vol->server_ino = 0;
> +                       vol->server_ino = false;
>                         break;
>                 case Opt_rwpidforward:
> -                       vol->rwpidforward = 1;
> +                       vol->rwpidforward = true;
>                         break;
>                 case Opt_cifsacl:
> -                       vol->cifs_acl = 1;
> +                       vol->cifs_acl = true;
>                         break;
>                 case Opt_nocifsacl:
> -                       vol->cifs_acl = 0;
> +                       vol->cifs_acl = false;
>                         break;
>                 case Opt_acl:
> -                       vol->no_psx_acl = 0;
> +                       vol->no_psx_acl = false;
>                         break;
>                 case Opt_noacl:
> -                       vol->no_psx_acl = 1;
> +                       vol->no_psx_acl = true;
>                         break;
>                 case Opt_locallease:
> -                       vol->local_lease = 1;
> +                       vol->local_lease = true;
>                         break;
>                 case Opt_sign:
>                         vol->sign = true;
> @@ -1486,7 +1486,7 @@ cifs_parse_mount_options(const char *mou
>                          * or per-smb connection option in the protocol
>                          * vol->secFlg |= CIFSSEC_MUST_SEAL;
>                          */
> -                       vol->seal = 1;
> +                       vol->seal = true;
>                         break;
>                 case Opt_noac:
>                         pr_warn("CIFS: Mount option noac not supported. Instead set /proc/fs/cifs/LookupCacheEnabled to 0\n");
> @@ -1664,7 +1664,7 @@ cifs_parse_mount_options(const char *mou
>
>                 case Opt_blank_user:
>                         /* null user, ie. anonymous authentication */
> -                       vol->nullauth = 1;
> +                       vol->nullauth = true;
>                         vol->username = NULL;
>                         break;
>                 case Opt_user:
> @@ -1986,7 +1986,7 @@ cifs_parse_mount_options(const char *mou
>         else if (override_gid == 1)
>                 pr_notice("CIFS: ignoring forcegid mount option specified with no gid= option.\n");
>
> -       if (got_version == false)
> +       if (!got_version)
>                 pr_warn("No dialect specified on mount. Default has changed to "
>                         "a more secure dialect, SMB3 (vers=3.0), from CIFS "
>                         "(SMB1). To use the less secure SMB1 dialect to access "
> @@ -2800,7 +2800,7 @@ cifs_get_tcon(struct cifs_ses *ses, stru
>                 }
>         } else if ((tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
>              && (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
> -            && (volume_info->nopersistent == false)) {
> +            && (!volume_info->nopersistent)) {
>                 cifs_dbg(FYI, "enabling persistent handles\n");
>                 tcon->use_persistent = true;
>         } else if (volume_info->resilient) {
> @@ -3289,13 +3289,13 @@ void reset_cifs_unix_caps(unsigned int x
>
>         if (vol_info && vol_info->no_linux_ext) {
>                 tcon->fsUnixInfo.Capability = 0;
> -               tcon->unix_ext = 0; /* Unix Extensions disabled */
> +               tcon->unix_ext = false; /* Unix Extensions disabled */
>                 cifs_dbg(FYI, "Linux protocol extensions disabled\n");
>                 return;
>         } else if (vol_info)
> -               tcon->unix_ext = 1; /* Unix Extensions supported */
> +               tcon->unix_ext = true; /* Unix Extensions supported */
>
> -       if (tcon->unix_ext == 0) {
> +       if (!tcon->unix_ext) {
>                 cifs_dbg(FYI, "Unix extensions disabled so not set on reconnect\n");
>                 return;
>         }
> @@ -3333,7 +3333,7 @@ void reset_cifs_unix_caps(unsigned int x
>                                         CIFS_MOUNT_POSIXACL;
>                 }
>
> -               if (vol_info && vol_info->posix_paths == 0)
> +               if (vol_info && !vol_info->posix_paths)
>                         cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
>                 else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
>                         cifs_dbg(FYI, "negotiate posix pathnames\n");
> @@ -3740,8 +3740,8 @@ try_mount_again:
>                 goto mount_fail_check;
>         }
>
> -       if ((volume_info->persistent == true) && ((ses->server->capabilities &
> -               SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) == 0)) {
> +       if ((volume_info->persistent) && ((ses->server->capabilities &
> +                                          SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) == 0)) {
>                 cifs_dbg(VFS, "persistent handles not supported by server\n");
>                 rc = -EOPNOTSUPP;
>                 goto mount_fail_check;
> @@ -3770,7 +3770,7 @@ try_mount_again:
>                         goto mount_fail_check;
>                 }
>         } else
> -               tcon->unix_ext = 0; /* server does not support them */
> +               tcon->unix_ext = false; /* server does not support them */
>
>         /* do not care if a following call succeed - informational */
>         if (!tcon->ipc && server->ops->qfs_tcon)
> @@ -4032,7 +4032,7 @@ CIFSTCon(const unsigned int xid, struct
>                         if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') &&
>                             (bcc_ptr[2] == 'C')) {
>                                 cifs_dbg(FYI, "IPC connection\n");
> -                               tcon->ipc = 1;
> +                               tcon->ipc = true;
>                         }
>                 } else if (length == 2) {
>                         if ((bcc_ptr[0] == 'A') && (bcc_ptr[1] == ':')) {
> @@ -4138,7 +4138,7 @@ cifs_setup_session(const unsigned int xi
>         struct TCP_Server_Info *server = ses->server;
>
>         ses->capabilities = server->capabilities;
> -       if (linuxExtEnabled == 0)
> +       if (!linuxExtEnabled)
>                 ses->capabilities &= (~server->vals->cap_unix);
>
>         cifs_dbg(FYI, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d\n",
> diff -u -p a/fs/cifs/file.c b/fs/cifs/file.c
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -702,7 +702,7 @@ cifs_reopen_file(struct cifsFileInfo *cf
>          * not dirty locally we could do this.
>          */
>         rc = server->ops->open(xid, &oparms, &oplock, NULL);
> -       if (rc == -ENOENT && oparms.reconnect == false) {
> +       if (rc == -ENOENT && !oparms.reconnect) {
>                 /* durable handle timeout is expired - open the file again */
>                 rc = server->ops->open(xid, &oparms, &oplock, NULL);
>                 /* indicate that we need to relock the file */
> diff -u -p a/fs/cifs/inode.c b/fs/cifs/inode.c
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -804,7 +804,7 @@ cifs_get_inode_info(struct inode **inode
>          */
>         if (*inode == NULL) {
>                 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
> -                       if (validinum == false) {
> +                       if (!validinum) {
>                                 if (server->ops->get_srv_inum)
>                                         tmprc = server->ops->get_srv_inum(xid,
>                                                 tcon, cifs_sb, full_path,
> @@ -820,7 +820,7 @@ cifs_get_inode_info(struct inode **inode
>                         fattr.cf_uniqueid = iunique(sb, ROOT_I);
>         } else {
>                 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&
> -                   validinum == false && server->ops->get_srv_inum) {
> +                   !validinum && server->ops->get_srv_inum) {
>                         /*
>                          * Pass a NULL tcon to ensure we don't make a round
>                          * trip to the server. This only works for SMB2+.
> diff -u -p a/fs/cifs/misc.c b/fs/cifs/misc.c
> --- a/fs/cifs/misc.c
> +++ b/fs/cifs/misc.c
> @@ -506,7 +506,7 @@ is_valid_oplock_break(char *buffer, stru
>  void
>  dump_smb(void *buf, int smb_buf_length)
>  {
> -       if (traceSMB == 0)
> +       if (!traceSMB)
>                 return;
>
>         print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_NONE, 8, 2, buf,
> diff -u -p a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
> --- a/fs/cifs/smb2misc.c
> +++ b/fs/cifs/smb2misc.c
> @@ -376,7 +376,7 @@ smb2_calc_size(void *buf)
>          */
>         len += le16_to_cpu(pdu->StructureSize2);
>
> -       if (has_smb2_data_area[le16_to_cpu(shdr->Command)] == false)
> +       if (!has_smb2_data_area[le16_to_cpu(shdr->Command)])
>                 goto calc_size_exit;
>
>         smb2_get_data_area_len(&offset, &data_length, hdr);
> diff -u -p a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -1664,7 +1664,7 @@ static long smb3_zero_range(struct file
>
>         /* if file not oplocked can't be sure whether asking to extend size */
>         if (!CIFS_CACHE_READ(cifsi))
> -               if (keep_size == false)
> +               if (!keep_size)
>                         return -EOPNOTSUPP;
>
>         /*
> @@ -1680,7 +1680,7 @@ static long smb3_zero_range(struct file
>          * this to zero the first part of the range then set the file size
>          * which for a non sparse file would zero the newly extended range
>          */
> -       if (keep_size == false)
> +       if (!keep_size)
>                 if (i_size_read(inode) < offset + len)
>                         return -EOPNOTSUPP;
>
> @@ -1749,7 +1749,7 @@ static long smb3_simple_falloc(struct fi
>
>         /* if file not oplocked can't be sure whether asking to extend size */
>         if (!CIFS_CACHE_READ(cifsi))
> -               if (keep_size == false)
> +               if (!keep_size)
>                         return -EOPNOTSUPP;
>
>         /*
> @@ -1758,7 +1758,7 @@ static long smb3_simple_falloc(struct fi
>          * then no need to do anything since file already allocated
>          */
>         if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) {
> -               if (keep_size == true)
> +               if (keep_size)
>                         return 0;
>                 /* check if extending file */
>                 else if (i_size_read(inode) >= off + len)
> @@ -1769,7 +1769,7 @@ static long smb3_simple_falloc(struct fi
>                         return -EOPNOTSUPP;
>         }
>
> -       if ((keep_size == true) || (i_size_read(inode) >= off + len)) {
> +       if ((keep_size) || (i_size_read(inode) >= off + len)) {
>                 /*
>                  * Check if falloc starts within first few pages of file
>                  * and ends within a few pages of the end of file to
> diff -u -p a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -617,7 +617,7 @@ int smb3_validate_negotiate(const unsign
>          * would also enable signing on the mount. Having validation of
>          * negotiate info for signed connections helps reduce attack vectors
>          */
> -       if (tcon->ses->server->sign == false)
> +       if (!tcon->ses->server->sign)
>                 return 0; /* validation requires signing */
>
>         vneg_inbuf.Capabilities =
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] afs: Fix bool initialization/comparison
  2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
                   ` (16 preceding siblings ...)
  2017-10-07 14:02 ` [PATCH] configfs: " Thomas Meyer
@ 2017-10-10 15:19 ` David Howells
  17 siblings, 0 replies; 33+ messages in thread
From: David Howells @ 2017-10-10 15:19 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: dhowells, linux-afs, linux-kernel

Thomas Meyer <thomas@m3y3r.de> wrote:

> Bool initializations should use true and false. Bool tests don't need
> comparisons.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Please rebase on top of:

	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=afs-2-experimental

Some of the code you're changing has been deleted.

David

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: Fix bool initialization/comparison
  2017-10-09  1:48       ` Chao Yu
@ 2017-10-10 17:41         ` Jaegeuk Kim
  0 siblings, 0 replies; 33+ messages in thread
From: Jaegeuk Kim @ 2017-10-10 17:41 UTC (permalink / raw)
  To: Chao Yu
  Cc: Joe Perches, Ju Hyung Park, Thomas Meyer, linux-f2fs-devel, linux-kernel

On 10/09, Chao Yu wrote:
> On 2017/10/8 3:30, Joe Perches wrote:
> > On Sat, 2017-10-07 at 23:33 +0900, Ju Hyung Park wrote:
> >> Isn't this bogus?
> >>
> >> "bool" type in Linux kernel is a typedef to "_Bool"
> >> and true/false is defined as 1 and 0 by enum at include/linux/stddef.h.
> > 
> > Bogus?  Well, not really.  It's just a neatening and it's
> > identical object code.
> > 
> > The idea is that true/false is more intelligible than 1/0
> > for a human reader.
> 
> Yes, that's just cleanup.
> 
> Hi Thomas, could you change the commit message a bit?
> 
> > 
> >> On Sat, Oct 7, 2017 at 11:02 PM, Thomas Meyer <thomas@m3y3r.de> wrote:
> >>> Bool initializations should use true and false. Bool tests don't need
> >>> comparisons.
> > []
> >>> diff -u -p a/fs/f2fs/data.c b/fs/f2fs/data.c
> > []
> >>> @@ -419,7 +419,7 @@ next:
> >>>         bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
> >>>
> >>>         /* set submitted = 1 as a return value */
> 
> Comment should be updated too.

I just merged the patch with a fix for this.

Thanks,

> 
> Thanks,
> 
> >>> -       fio->submitted = 1;
> >>> +       fio->submitted = true;
> >>>
> >>>         inc_page_count(sbi, WB_DATA_TYPE(bio_page));
> >>>
> > 
> > And it's probably better to change the comment too.
> > 
> > 
> > .
> > 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] selinux: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] selinux: " Thomas Meyer
@ 2017-10-10 23:17   ` Casey Schaufler
  2017-10-10 23:19   ` Casey Schaufler
  1 sibling, 0 replies; 33+ messages in thread
From: Casey Schaufler @ 2017-10-10 23:17 UTC (permalink / raw)
  To: Thomas Meyer, paul, sds, eparis, james.l.morris, serge, selinux,
	linux-security-module, linux-kernel

On 10/7/2017 7:02 AM, Thomas Meyer wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
>
> diff -u -p a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c
> --- a/security/selinux/ss/mls.c
> +++ b/security/selinux/ss/mls.c
> @@ -550,7 +550,7 @@ int mls_compute_sid(struct context *scon
>  
>  		/* Fallthrough */
>  	case AVTAB_CHANGE:
> -		if ((tclass == policydb.process_class) || (sock == true))
> +		if ((tclass == policydb.process_class) || (sock))

bool tests don't need parentheses, either.

	+	if ((tclass == policydb.process_class) || sock)

>  			/* Use the process MLS attributes. */
>  			return mls_context_cpy(newcontext, scontext);
>  		else
> diff -u -p a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -1656,7 +1656,7 @@ static int security_compute_sid(u32 ssid
>  	} else if (cladatum && cladatum->default_role == DEFAULT_TARGET) {
>  		newcontext.role = tcontext->role;
>  	} else {
> -		if ((tclass == policydb.process_class) || (sock == true))
> +		if ((tclass == policydb.process_class) || (sock))

Likewise

>  			newcontext.role = scontext->role;
>  		else
>  			newcontext.role = OBJECT_R_VAL;
> @@ -1668,7 +1668,7 @@ static int security_compute_sid(u32 ssid
>  	} else if (cladatum && cladatum->default_type == DEFAULT_TARGET) {
>  		newcontext.type = tcontext->type;
>  	} else {
> -		if ((tclass == policydb.process_class) || (sock == true)) {
> +		if ((tclass == policydb.process_class) || (sock)) {

On more time.

>  			/* Use the type of process. */
>  			newcontext.type = scontext->type;
>  		} else {
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] selinux: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] selinux: " Thomas Meyer
  2017-10-10 23:17   ` Casey Schaufler
@ 2017-10-10 23:19   ` Casey Schaufler
  2017-10-13 22:40     ` Paul Moore
  1 sibling, 1 reply; 33+ messages in thread
From: Casey Schaufler @ 2017-10-10 23:19 UTC (permalink / raw)
  To: Thomas Meyer, paul, sds, eparis, james.l.morris, serge, selinux,
	linux-security-module, linux-kernel

On 10/7/2017 7:02 AM, Thomas Meyer wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
>
> diff -u -p a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c
> --- a/security/selinux/ss/mls.c
> +++ b/security/selinux/ss/mls.c
> @@ -550,7 +550,7 @@ int mls_compute_sid(struct context *scon
>  
>  		/* Fallthrough */
>  	case AVTAB_CHANGE:
> -		if ((tclass == policydb.process_class) || (sock == true))
> +		if ((tclass == policydb.process_class) || (sock))

How about

	+	if ((tclass == policydb.process_class) || sock)

>  			/* Use the process MLS attributes. */
>  			return mls_context_cpy(newcontext, scontext);
>  		else
> diff -u -p a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -1656,7 +1656,7 @@ static int security_compute_sid(u32 ssid
>  	} else if (cladatum && cladatum->default_role == DEFAULT_TARGET) {
>  		newcontext.role = tcontext->role;
>  	} else {
> -		if ((tclass == policydb.process_class) || (sock == true))
> +		if ((tclass == policydb.process_class) || (sock))

Excessive ()

>  			newcontext.role = scontext->role;
>  		else
>  			newcontext.role = OBJECT_R_VAL;
> @@ -1668,7 +1668,7 @@ static int security_compute_sid(u32 ssid
>  	} else if (cladatum && cladatum->default_type == DEFAULT_TARGET) {
>  		newcontext.type = tcontext->type;
>  	} else {
> -		if ((tclass == policydb.process_class) || (sock == true)) {
> +		if ((tclass == policydb.process_class) || (sock)) {

Excessive ()

>  			/* Use the type of process. */
>  			newcontext.type = scontext->type;
>  		} else {
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] selinux: Fix bool initialization/comparison
  2017-10-10 23:19   ` Casey Schaufler
@ 2017-10-13 22:40     ` Paul Moore
  0 siblings, 0 replies; 33+ messages in thread
From: Paul Moore @ 2017-10-13 22:40 UTC (permalink / raw)
  To: Thomas Meyer
  Cc: Stephen Smalley, Eric Paris, James Morris, serge, selinux,
	linux-security-module, linux-kernel, Casey Schaufler

On Tue, Oct 10, 2017 at 7:19 PM, Casey Schaufler <casey@schaufler-ca.com> wrote:
> On 10/7/2017 7:02 AM, Thomas Meyer wrote:
>> Bool initializations should use true and false. Bool tests don't need
>> comparisons.
>>
>> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
>> ---

Hi Thomas,

Thank you for submitting this patch, but it really doesn't add any
value to the SELinux code so I'm not going to merge it at this time.
If you would like to contribute to SELinux there are a number of
issues open on our GitHub page that you could look into resolving,
those patches would be very welcome.

* https://github.com/SELinuxProject

-Paul

>> diff -u -p a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c
>> --- a/security/selinux/ss/mls.c
>> +++ b/security/selinux/ss/mls.c
>> @@ -550,7 +550,7 @@ int mls_compute_sid(struct context *scon
>>
>>               /* Fallthrough */
>>       case AVTAB_CHANGE:
>> -             if ((tclass == policydb.process_class) || (sock == true))
>> +             if ((tclass == policydb.process_class) || (sock))
>
> How about
>
>         +       if ((tclass == policydb.process_class) || sock)
>
>>                       /* Use the process MLS attributes. */
>>                       return mls_context_cpy(newcontext, scontext);
>>               else
>> diff -u -p a/security/selinux/ss/services.c b/security/selinux/ss/services.c
>> --- a/security/selinux/ss/services.c
>> +++ b/security/selinux/ss/services.c
>> @@ -1656,7 +1656,7 @@ static int security_compute_sid(u32 ssid
>>       } else if (cladatum && cladatum->default_role == DEFAULT_TARGET) {
>>               newcontext.role = tcontext->role;
>>       } else {
>> -             if ((tclass == policydb.process_class) || (sock == true))
>> +             if ((tclass == policydb.process_class) || (sock))
>
> Excessive ()
>
>>                       newcontext.role = scontext->role;
>>               else
>>                       newcontext.role = OBJECT_R_VAL;
>> @@ -1668,7 +1668,7 @@ static int security_compute_sid(u32 ssid
>>       } else if (cladatum && cladatum->default_type == DEFAULT_TARGET) {
>>               newcontext.type = tcontext->type;
>>       } else {
>> -             if ((tclass == policydb.process_class) || (sock == true)) {
>> +             if ((tclass == policydb.process_class) || (sock)) {
>
> Excessive ()
>
>>                       /* Use the type of process. */
>>                       newcontext.type = scontext->type;
>>               } else {
>>
>

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] configfs: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] configfs: " Thomas Meyer
@ 2017-10-19 14:08   ` Christoph Hellwig
  0 siblings, 0 replies; 33+ messages in thread
From: Christoph Hellwig @ 2017-10-19 14:08 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: jlbec, hch, linux-kernel

On Sat, Oct 07, 2017 at 04:02:21PM +0200, Thomas Meyer wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Thanks Thomas,

applied to the configfs tree for 4.15.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH] pstore: Fix bool initialization/comparison
  2017-10-07 14:02 ` [PATCH] pstore: " Thomas Meyer
@ 2018-11-29 23:21   ` Kees Cook
  0 siblings, 0 replies; 33+ messages in thread
From: Kees Cook @ 2018-11-29 23:21 UTC (permalink / raw)
  To: Thomas Meyer
  Cc: Anton Vorontsov, Colin Cross, Tony Luck, LKML, Joel Fernandes

On Sat, Oct 7, 2017 at 7:24 AM Thomas Meyer <thomas@m3y3r.de> wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons.
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

I totally missed this email (now over a year ago!)

However, since it's still correct and applies, I've taken it for -next
now. :) Thanks!

-Kees

> ---
>
> diff -u -p a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c
> --- a/fs/pstore/ftrace.c
> +++ b/fs/pstore/ftrace.c
> @@ -148,7 +148,7 @@ void pstore_unregister_ftrace(void)
>         mutex_lock(&pstore_ftrace_lock);
>         if (pstore_ftrace_enabled) {
>                 unregister_ftrace_function(&pstore_ftrace_ops);
> -               pstore_ftrace_enabled = 0;
> +               pstore_ftrace_enabled = false;
>         }
>         mutex_unlock(&pstore_ftrace_lock);
>


-- 
Kees Cook

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2018-11-29 23:22 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-07 14:02 Cocci spatch "boolinit" - v4.14-rc1 Thomas Meyer
2017-10-07 14:02 ` [PATCH] f2fs: Fix bool initialization/comparison Thomas Meyer
2017-10-07 14:33   ` [f2fs-dev] " Ju Hyung Park
2017-10-07 19:30     ` Joe Perches
2017-10-09  1:48       ` Chao Yu
2017-10-10 17:41         ` Jaegeuk Kim
2017-10-07 14:02 ` [PATCH] cifs: " Thomas Meyer
2017-10-10  1:14   ` Nico Kadel-Garcia
2017-10-07 14:02 ` [PATCH] ima: " Thomas Meyer
2017-10-07 14:02 ` [PATCH] nfsd: " Thomas Meyer
2017-10-07 14:02 ` [PATCH] NFS: " Thomas Meyer
2017-10-07 14:02 ` [PATCH] pstore: " Thomas Meyer
2018-11-29 23:21   ` Kees Cook
2017-10-07 14:02 ` [PATCH] afs: " Thomas Meyer
2017-10-07 14:02 ` [PATCH] xfs: " Thomas Meyer
2017-10-09 14:24   ` Brian Foster
2017-10-07 14:02 ` [PATCH] ceph: " Thomas Meyer
2017-10-09  1:52   ` Yan, Zheng
2017-10-07 14:02 ` [PATCH] bfq: " Thomas Meyer
2017-10-07 14:02 ` [PATCH] proc: " Thomas Meyer
2017-10-07 14:02 ` [PATCH] exofs: " Thomas Meyer
2017-10-07 14:02 ` [PATCH] apparmor: " Thomas Meyer
2017-10-07 17:18   ` John Johansen
2017-10-07 14:02 ` [PATCH] ext4: " Thomas Meyer
2017-10-07 14:02 ` [PATCH] btrfs: " Thomas Meyer
2017-10-09 16:05   ` David Sterba
2017-10-07 14:02 ` [PATCH] selinux: " Thomas Meyer
2017-10-10 23:17   ` Casey Schaufler
2017-10-10 23:19   ` Casey Schaufler
2017-10-13 22:40     ` Paul Moore
2017-10-07 14:02 ` [PATCH] configfs: " Thomas Meyer
2017-10-19 14:08   ` Christoph Hellwig
2017-10-10 15:19 ` [PATCH] afs: " David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).