From: tboegi@web.de
To: git@vger.kernel.org, svnpenn@gmail.com
Cc: "Torsten Bögershausen" <tboegi@web.de>
Subject: [PATCH v2 2/3] offset_1st_component(), dos_drive_prefix() return size_t
Date: Fri, 7 Dec 2018 18:04:58 +0100 [thread overview]
Message-ID: <20181207170458.9036-1-tboegi@web.de> (raw)
In-Reply-To: <5bf18396.1c69fb81.20780.2b1d@mx.google.com>
From: Torsten Bögershausen <tboegi@web.de>
Change the return value for offset_1st_component(),
has_dos_drive_prefix() and skip_dos_drive_prefix from int into size_t,
which is the natural type for length of data in memory.
While at it, remove possible "parameter not used" warnings in for the
non-Windows builds in git-compat-util.h
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
abspath.c | 2 +-
compat/mingw-cygwin.c | 6 +++---
compat/mingw-cygwin.h | 4 ++--
git-compat-util.h | 8 +++++---
setup.c | 4 ++--
5 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/abspath.c b/abspath.c
index 9857985329..12055a1d8f 100644
--- a/abspath.c
+++ b/abspath.c
@@ -51,7 +51,7 @@ static void get_next_component(struct strbuf *next, struct strbuf *remaining)
/* copies root part from remaining to resolved, canonicalizing it on the way */
static void get_root_part(struct strbuf *resolved, struct strbuf *remaining)
{
- int offset = offset_1st_component(remaining->buf);
+ size_t offset = offset_1st_component(remaining->buf);
strbuf_reset(resolved);
strbuf_add(resolved, remaining->buf, offset);
diff --git a/compat/mingw-cygwin.c b/compat/mingw-cygwin.c
index c63d7acb9c..5552c3ac20 100644
--- a/compat/mingw-cygwin.c
+++ b/compat/mingw-cygwin.c
@@ -1,13 +1,13 @@
#include "../git-compat-util.h"
-int mingw_cygwin_skip_dos_drive_prefix(char **path)
+size_t mingw_cygwin_skip_dos_drive_prefix(char **path)
{
- int ret = has_dos_drive_prefix(*path);
+ size_t ret = has_dos_drive_prefix(*path);
*path += ret;
return ret;
}
-int mingw_cygwin_offset_1st_component(const char *path)
+size_t mingw_cygwin_offset_1st_component(const char *path)
{
char *pos = (char *)path;
diff --git a/compat/mingw-cygwin.h b/compat/mingw-cygwin.h
index 66ccc909ae..0e8a0c9074 100644
--- a/compat/mingw-cygwin.h
+++ b/compat/mingw-cygwin.h
@@ -1,6 +1,6 @@
#define has_dos_drive_prefix(path) \
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
-int mingw_cygwin_skip_dos_drive_prefix(char **path);
+size_t mingw_cygwin_skip_dos_drive_prefix(char **path);
#define skip_dos_drive_prefix mingw_cygwin_skip_dos_drive_prefix
static inline int mingw_cygwin_is_dir_sep(int c)
{
@@ -16,5 +16,5 @@ static inline char *mingw_cygwin_find_last_dir_sep(const char *path)
return ret;
}
#define find_last_dir_sep mingw_cygwin_find_last_dir_sep
-int mingw_cygwin_offset_1st_component(const char *path);
+size_t mingw_cygwin_offset_1st_component(const char *path);
#define offset_1st_component mingw_cygwin_offset_1st_component
diff --git a/git-compat-util.h b/git-compat-util.h
index 7ece969b22..65eaaf0d50 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -355,16 +355,18 @@ static inline int noop_core_config(const char *var, const char *value, void *cb)
#endif
#ifndef has_dos_drive_prefix
-static inline int git_has_dos_drive_prefix(const char *path)
+static inline size_t git_has_dos_drive_prefix(const char *path)
{
+ (void)path;
return 0;
}
#define has_dos_drive_prefix git_has_dos_drive_prefix
#endif
#ifndef skip_dos_drive_prefix
-static inline int git_skip_dos_drive_prefix(char **path)
+static inline size_t git_skip_dos_drive_prefix(char **path)
{
+ (void)path;
return 0;
}
#define skip_dos_drive_prefix git_skip_dos_drive_prefix
@@ -379,7 +381,7 @@ static inline int git_is_dir_sep(int c)
#endif
#ifndef offset_1st_component
-static inline int git_offset_1st_component(const char *path)
+static inline size_t git_offset_1st_component(const char *path)
{
return is_dir_sep(path[0]);
}
diff --git a/setup.c b/setup.c
index 1be5037f12..538bc1ff99 100644
--- a/setup.c
+++ b/setup.c
@@ -29,7 +29,7 @@ static int abspath_part_inside_repo(char *path)
size_t len;
size_t wtlen;
char *path0;
- int off;
+ size_t off;
const char *work_tree = get_git_work_tree();
if (!work_tree)
@@ -800,7 +800,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
struct repository_format *repo_fmt,
int *nongit_ok)
{
- int root_len;
+ size_t root_len;
if (check_repository_format_gently(".", repo_fmt, nongit_ok))
return NULL;
--
2.19.0.271.gfe8321ec05
next prev parent reply other threads:[~2018-12-07 17:05 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-18 15:21 Cygwin Git with Windows paths Steven Penny
2018-11-18 15:41 ` Torsten Bögershausen
2018-11-18 16:23 ` Steven Penny
2018-11-18 17:15 ` Torsten Bögershausen
2018-11-18 17:34 ` Steven Penny
2018-11-18 18:28 ` Torsten Bögershausen
2018-11-18 19:00 ` Steven Penny
2018-11-19 0:06 ` Junio C Hamano
2018-11-19 2:11 ` Randall S. Becker
2018-11-19 3:33 ` Junio C Hamano
2018-11-19 5:20 ` Torsten Bögershausen
2018-11-20 0:17 ` Steven Penny
2018-11-20 10:36 ` Torsten Bögershausen
2018-11-20 12:51 ` Steven Penny
2018-11-19 12:22 ` Randall S. Becker
2018-11-26 17:32 ` [PATCH v1/RFC 1/1] 'git clone <url> C:\cygwin\home\USER\repo' is working (again) tboegi
2018-11-27 0:35 ` Steven Penny
2018-11-27 1:16 ` Junio C Hamano
2018-11-27 2:49 ` Steven Penny
2018-11-27 5:23 ` Junio C Hamano
2018-11-27 6:20 ` Steven Penny
2018-11-27 12:55 ` Johannes Schindelin
2018-11-28 4:10 ` Junio C Hamano
2018-11-28 5:55 ` J.H. van de Water
2018-11-28 8:46 ` Johannes Schindelin
2018-11-28 9:01 ` Houder
2018-11-28 9:35 ` Johannes Schindelin
2018-11-27 20:10 ` Achim Gratz
2018-11-27 12:49 ` Johannes Schindelin
2018-11-28 4:12 ` Junio C Hamano
2018-11-27 20:05 ` Achim Gratz
2018-12-07 17:04 ` [PATCH v2 1/3] git " tboegi
2018-12-07 21:53 ` Johannes Schindelin
2018-12-08 0:49 ` Steven Penny
2018-12-10 8:46 ` Johannes Schindelin
2018-12-10 12:45 ` Steven Penny
2018-12-11 13:39 ` Johannes Schindelin
2018-12-12 0:42 ` Steven Penny
2018-12-12 7:29 ` Johannes Sixt
2018-12-12 12:40 ` Steven Penny
2018-12-13 3:52 ` Junio C Hamano
2018-12-12 13:33 ` Johannes Schindelin
2018-12-12 3:47 ` Elijah Newren
2018-12-12 13:57 ` Johannes Schindelin
2018-12-07 17:04 ` tboegi [this message]
2018-12-07 17:05 ` [PATCH v2 3/3] Refactor mingw_cygwin_offset_1st_component() tboegi
2018-12-07 22:18 ` Johannes Schindelin
2018-12-08 15:11 ` [PATCH v3 1/1] git clone <url> C:\cygwin\home\USER\repo' is working (again) tboegi
2018-12-08 16:24 ` Steven Penny
2018-12-09 1:39 ` Junio C Hamano
2018-12-10 8:32 ` Johannes Schindelin
2018-12-11 6:12 ` Torsten Bögershausen
2018-12-11 13:28 ` Johannes Schindelin
2018-12-11 18:55 ` Torsten Bögershausen
2018-12-15 4:33 ` [PATCH v4 " tboegi
2019-05-02 7:48 ` Achim Gratz
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=20181207170458.9036-1-tboegi@web.de \
--to=tboegi@web.de \
--cc=git@vger.kernel.org \
--cc=svnpenn@gmail.com \
/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).