git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Vedant Bassi <sharababy.dev@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH][GSoc] Changed signed flags to unsigned type
Date: Thu, 9 Mar 2017 09:54:27 +0530	[thread overview]
Message-ID: <CACczA6V6t4f6TTT=CJfqsuCtbYuM1QNh8AgtOwqRt7pz4VMeRA@mail.gmail.com> (raw)

As part of my microproject :

Use unsigned integral type for collection of bits:
Pick one field of a structure that (1) is of signed integral type and
(2) is used as a collection of multiple bits. Discuss if there is a
good reason why it has to be a signed integral field and change it to
an unsigned type otherwise.

More ref: https://public-inbox.org/git/xmqqsiebrlez.fsf@gitster.dls.corp.google.com
http://stackoverflow.com/questions/29795170/usage-of-signed-vs-unsigned-variables-for-flags-in-c

I have found several structures where a signed int was used on flags
for bitwise & to check various cases.


diff --git a/bisect.h b/bisect.h

index a979a7f..4b562a8 100644

--- a/bisect.h

+++ b/bisect.h

@@ -16,6 +16,8 @@ extern struct commit_list *filter_skipped(struct
commit_list *list,



 struct rev_list_info {

        struct rev_info *revs;

+

+ // int flags changed to unsigned int

        unsigned int flags;

        int show_timestamp;

        int hdr_termination;

diff --git a/builtin/add.c b/builtin/add.c

index 9f53f02..1212eea 100644

--- a/builtin/add.c

+++ b/builtin/add.c

@@ -26,6 +26,8 @@ static int patch_interactive, add_interactive,
edit_interactive;

 static int take_worktree_changes;



 struct update_callback_data {

+

+ // flags supposed to be unsigned

        int flags;

        int add_errors;

 };

diff --git a/parse-options.h b/parse-options.h

index dcd8a09..ad180c9 100644

--- a/parse-options.h

+++ b/parse-options.h

@@ -107,7 +107,9 @@ struct option {

        const char *argh;

        const char *help;



-   int flags;

+ // int flags changed to unsigned

+

+ unsigned int flags;

        parse_opt_cb *callback;

        intptr_t defval;

 };

@@ -201,7 +203,10 @@ struct parse_opt_ctx_t {

        const char **out;

        int argc, cpidx, total;

        const char *opt;

-   int flags;

+

+ // int flags changed to unsigned

+

+ unsigned int flags;

        const char *prefix;

 };



-------

result : the changes were made in bisect.h , parse-options.h and  builtin/add.c

I have not yet  tested these changes.

             reply	other threads:[~2017-03-09  4:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-09  4:24 Vedant Bassi [this message]
2017-03-09  7:49 ` [PATCH][GSoc] Changed signed flags to unsigned type Christian Couder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACczA6V6t4f6TTT=CJfqsuCtbYuM1QNh8AgtOwqRt7pz4VMeRA@mail.gmail.com' \
    --to=sharababy.dev@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).