[PATCH] vfs: Use defined macro(like BITPS_PER_BYTE) in fs/file.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use defined macro(like BITPS_PER_BYTE) instead of some const number(like 8)
in fs/file.c. So, replace 8 with BITS_PER_BYTE, 8 * sizeof(long) with
BITS_PER_LONG in file fs/file.c. Since the two macro are defined, so use them.

Signed-off-by: Liu Aleaxander <Aleaxander@xxxxxxxxx>
---
 fs/file.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index 34bb7f7..f4d3d2c 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -278,11 +278,11 @@ static int count_open_files(struct fdtable *fdt)
        int i;

        /* Find the last open fd */
-       for (i = size/(8*sizeof(long)); i > 0; ) {
+       for (i = size/BITS_PER_LONG; i > 0; ) {
                if (fdt->open_fds->fds_bits[--i])
                        break;
        }
-       i = (i+1) * 8 * sizeof(long);
+       i = (i+1) * BITS_PER_LONG;
        return i;
 }

@@ -360,9 +360,9 @@ struct files_struct *dup_fd(struct files_struct
*oldf, int *errorp)
        new_fds = new_fdt->fd;

        memcpy(new_fdt->open_fds->fds_bits,
-               old_fdt->open_fds->fds_bits, open_files/8);
+               old_fdt->open_fds->fds_bits, open_files/BITS_PER_BYTE);
        memcpy(new_fdt->close_on_exec->fds_bits,
-               old_fdt->close_on_exec->fds_bits, open_files/8);
+               old_fdt->close_on_exec->fds_bits, open_files/BITS_PER_BYTE);

        for (i = open_files; i != 0; i--) {
                struct file *f = *old_fds++;
@@ -388,8 +388,8 @@ struct files_struct *dup_fd(struct files_struct
*oldf, int *errorp)
        memset(new_fds, 0, size);

        if (new_fdt->max_fds > open_files) {
-               int left = (new_fdt->max_fds-open_files)/8;
-               int start = open_files / (8 * sizeof(unsigned long));
+               int left = (new_fdt->max_fds-open_files)/BITS_PER_BYTE;
+               int start = open_files / BITS_PER_LONG;

                memset(&new_fdt->open_fds->fds_bits[start], 0, left);
                memset(&new_fdt->close_on_exec->fds_bits[start], 0, left);
--
1.7.0.1
        new_fds = new_fdt->fd;

        memcpy(new_fdt->open_fds->fds_bits,
-               old_fdt->open_fds->fds_bits, open_files/8);
+               old_fdt->open_fds->fds_bits, open_files/BITS_PER_BYTE);
        memcpy(new_fdt->close_on_exec->fds_bits,
-               old_fdt->close_on_exec->fds_bits, open_files/8);
+               old_fdt->close_on_exec->fds_bits, open_files/BITS_PER_BYTE);

        for (i = open_files; i != 0; i--) {
                struct file *f = *old_fds++;
@@ -388,8 +388,8 @@ struct files_struct *dup_fd(struct files_struct
*oldf, int *errorp)
        memset(new_fds, 0, size);

        if (new_fdt->max_fds > open_files) {
-               int left = (new_fdt->max_fds-open_files)/8;
-               int start = open_files / (8 * sizeof(unsigned long));
+               int left = (new_fdt->max_fds-open_files)/BITS_PER_BYTE;
+               int start = open_files / BITS_PER_LONG;

                memset(&new_fdt->open_fds->fds_bits[start], 0, left);
                memset(&new_fdt->close_on_exec->fds_bits[start], 0, left);
--
1.7.0.1


--
Thanks & regards
Liu Aleaxander
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux