johnmehr / gitup

A minimalist, dependency-free FreeBSD program to clone/pull Git repositories.
BSD 2-Clause "Simplified" License
50 stars 9 forks source link

NetBSD port? #76

Open 0-wiz-0 opened 2 years ago

0-wiz-0 commented 2 years ago

It'd be great to have a NetBSD port for this. I tried building it on NetBSD, but the build failed mostly due to its use of ucl_* - private/ucl/ucl.h does not exist on NetBSD. Ignoring that, WARNS=6 on NetBSD also enables -Werror=conversion and -Werror=sign-conversionwhich cause compilation errors.

Except for these bigger items, I had to wrap the libutil.h include in an #ifdef __FreeBSD__ and define CLOCK_MONOTONIC_FAST to CLOCK_MONOTONIC to make the build progress (until it hits the ucl issues).

johnmehr commented 2 years ago

I think I got all of the errors generated when including -Werror=conversion and -Werror=sign-conversion fixed. How does it look?

0-wiz-0 commented 2 years ago

I've commented out the ucl and libutil headers, and this is what remains (on NetBSD):

gitup.c:158:56: error: unknown type name ‘ucl_object_t’
  158 | static void     load_config_section(connector *, const ucl_object_t *);
      |                                                        ^~~~~~~~~~~~
gitup.c: In function ‘illegible_hash’:
gitup.c:354:13: error: conversion from ‘int’ to ‘char’ may change value [-Werror=conversion]
  354 |   hash[x] = 16 * (hash_buffer[x * 2] -
      |             ^~
gitup.c: In function ‘scan_local_repository’:
gitup.c:1061:58: error: conversion to ‘int’ from ‘__mode_t’ {aka ‘unsigned int’} may change the sign of the result [-Werror=sign-conversion]
 1061 |      new_node->hash = calculate_file_hash(full_path, file.st_mode);
      |                                                      ~~~~^~~~~~~~
gitup.c: In function ‘process_command’:
gitup.c:1408:22: error: ‘CLOCK_MONOTONIC_FAST’ undeclared (first use in this function); did you mean ‘CLOCK_MONOTONIC’?
 1408 |    if (clock_gettime(CLOCK_MONOTONIC_FAST, &now) == -1)
      |                      ^~~~~~~~~~~~~~~~~~~~
      |                      CLOCK_MONOTONIC
gitup.c:1408:22: note: each undeclared identifier is reported only once for each function it appears in
gitup.c:1480:21: error: conversion to ‘long unsigned int’ from ‘ssize_t’ {aka ‘long int’} may change the sign of the result [-Werror=sign-conversion]
 1480 |      bytes_expected += (uint64_t)strtol(
      |                     ^~
gitup.c:1480:24: error: conversion to ‘ssize_t’ {aka ‘long int’} from ‘long unsigned int’ may change the sign of the result [-Werror=sign-conversion]
 1480 |      bytes_expected += (uint64_t)strtol(
      |                        ^
In file included from /usr/include/ctype.h:100,
                 from gitup.c:41:
gitup.c: In function ‘store_object’:
gitup.c:2148:26: error: array subscript has type ‘char’ [-Werror=char-subscripts]
 2148 |      if (!isxdigit(parent[x]))
      |                          ^
gitup.c: In function ‘unpack_objects’:
gitup.c:2260:17: error: conversion to ‘uint32_t’ {aka ‘unsigned int’} from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2260 |    file_bits  = session->response[position] & (stream_bytes == 0 ? 0x0F : 0x7F);
      |                 ^~~~~~~
gitup.c:2333:15: error: conversion from ‘uLong’ {aka ‘long unsigned int’} to ‘uint32_t’ {aka ‘unsigned int’} may change value [-Werror=conversion]
 2333 |   position += stream.total_in;
      |               ^~~~~~
gitup.c:2355:12: error: conversion to ‘uint64_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Werror=sign-conversion]
 2355 |    tot_len += buffer_size;
      |            ^~
gitup.c:2355:15: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘int’ may change value [-Werror=conversion]
 2355 |    tot_len += buffer_size;
      |               ^~~~~~~~~~~
gitup.c: In function ‘apply_deltas’:
gitup.c:2454:12: error: variable ‘old_file_size’ set but not used [-Werror=unused-but-set-variable]
 2454 |  uint32_t  old_file_size = 0, new_file_size = 0, new_position = 0;
      |            ^~~~~~~~~~~~~
gitup.c: In function ‘save_repairs’:
gitup.c:2868:16: error: conversion to ‘int’ from ‘__mode_t’ {aka ‘unsigned int’} may change the sign of the result [-Werror=sign-conversion]
 2868 |      found_file->mode);
      |      ~~~~~~~~~~^~~~~~
gitup.c: At top level:
gitup.c:3135:47: error: unknown type name ‘ucl_object_t’
 3135 | load_config_section(connector *session, const ucl_object_t *section)
      |                                               ^~~~~~~~~~~~
gitup.c: In function ‘load_config_section’:
gitup.c:3137:8: error: unknown type name ‘ucl_object_t’
 3137 |  const ucl_object_t *pair = NULL, *ignore = NULL;
      |        ^~~~~~~~~~~~
gitup.c:3138:2: error: unknown type name ‘ucl_object_iter_t’
 3138 |  ucl_object_iter_t   its = NULL, iti = NULL;
      |  ^~~~~~~~~~~~~~~~~
gitup.c:3138:28: error: initialization of ‘int’ from ‘void *’ makes integer from pointer without a cast [-Werror=int-conversion]
 3138 |  ucl_object_iter_t   its = NULL, iti = NULL;
      |                            ^~~~
gitup.c:3138:40: error: initialization of ‘int’ from ‘void *’ makes integer from pointer without a cast [-Werror=int-conversion]
 3138 |  ucl_object_iter_t   its = NULL, iti = NULL;
      |                                        ^~~~
gitup.c:3145:8: error: implicit declaration of function ‘ucl_object_iterate_new’ [-Werror=implicit-function-declaration]
 3145 |  its = ucl_object_iterate_new(section);
      |        ^~~~~~~~~~~~~~~~~~~~~~
gitup.c:3147:17: error: implicit declaration of function ‘ucl_object_iterate_safe’ [-Werror=implicit-function-declaration]
 3147 |  while ((pair = ucl_object_iterate_safe(its, true))) {
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
gitup.c:3147:15: error: assignment to ‘const int *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3147 |  while ((pair = ucl_object_iterate_safe(its, true))) {
      |               ^
gitup.c:3148:13: error: implicit declaration of function ‘ucl_object_key’ [-Werror=implicit-function-declaration]
 3148 |   key     = ucl_object_key(pair);
      |             ^~~~~~~~~~~~~~
gitup.c:3148:11: error: assignment to ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3148 |   key     = ucl_object_key(pair);
      |           ^
gitup.c:3149:13: error: implicit declaration of function ‘ucl_object_tostring’ [-Werror=implicit-function-declaration]
 3149 |   string  = ucl_object_tostring(pair);
      |             ^~~~~~~~~~~~~~~~~~~
gitup.c:3149:11: error: assignment to ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3149 |   string  = ucl_object_tostring(pair);
      |           ^
gitup.c:3150:13: error: implicit declaration of function ‘ucl_object_toboolean’ [-Werror=implicit-function-declaration]
 3150 |   boolean = ucl_object_toboolean(pair);
      |             ^~~~~~~~~~~~~~~~~~~~
gitup.c:3152:7: error: implicit declaration of function ‘ucl_object_type’ [-Werror=implicit-function-declaration]
 3152 |   if (ucl_object_type(pair) == UCL_INT)
      |       ^~~~~~~~~~~~~~~
gitup.c:3152:32: error: ‘UCL_INT’ undeclared (first use in this function); did you mean ‘RC4_INT’?
 3152 |   if (ucl_object_type(pair) == UCL_INT)
      |                                ^~~~~~~
      |                                RC4_INT
gitup.c:3153:14: error: implicit declaration of function ‘ucl_object_toint’ [-Werror=implicit-function-declaration]
 3153 |    integer = ucl_object_toint(pair);
      |              ^~~~~~~~~~~~~~~~
gitup.c:3154:37: error: ‘UCL_STRING’ undeclared (first use in this function)
 3154 |   else if (ucl_object_type(pair) == UCL_STRING)
      |                                     ^~~~~~~~~~
gitup.c:3205:46: error: ‘UCL_ARRAY’ undeclared (first use in this function)
 3205 |   if ((ignores) && (ucl_object_type(pair) == UCL_ARRAY)) {
      |                                              ^~~~~~~~~
gitup.c:3208:19: error: assignment to ‘const int *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3208 |    while ((ignore = ucl_object_iterate_safe(iti, true))) {
      |                   ^
gitup.c:3209:12: error: assignment to ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3209 |     string = ucl_object_tostring(ignore);
      |            ^
gitup.c:3233:4: error: implicit declaration of function ‘ucl_object_iterate_free’ [-Werror=implicit-function-declaration]
 3233 |    ucl_object_iterate_free(iti);
      |    ^~~~~~~~~~~~~~~~~~~~~~~
gitup.c: In function ‘load_config’:
gitup.c:3322:8: error: unknown type name ‘ucl_object_t’
 3322 |  const ucl_object_t *section = NULL;
      |        ^~~~~~~~~~~~
gitup.c:3323:2: error: unknown type name ‘ucl_object_t’
 3323 |  ucl_object_t       *object = NULL;
      |  ^~~~~~~~~~~~
gitup.c:3324:2: error: unknown type name ‘ucl_object_iter_t’
 3324 |  ucl_object_iter_t   it = NULL;
      |  ^~~~~~~~~~~~~~~~~
gitup.c:3324:27: error: initialization of ‘int’ from ‘void *’ makes integer from pointer without a cast [-Werror=int-conversion]
 3324 |  ucl_object_iter_t   it = NULL;
      |                           ^~~~
gitup.c:3342:11: error: implicit declaration of function ‘ucl_parser_new’ [-Werror=implicit-function-declaration]
 3342 |  parser = ucl_parser_new(0);
      |           ^~~~~~~~~~~~~~
gitup.c:3342:9: error: assignment to ‘struct ucl_parser *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3342 |  parser = ucl_parser_new(0);
      |         ^
gitup.c:3344:6: error: implicit declaration of function ‘ucl_parser_add_file’ [-Werror=implicit-function-declaration]
 3344 |  if (ucl_parser_add_file(parser, configuration_file) == false) {
      |      ^~~~~~~~~~~~~~~~~~~
gitup.c:3347:4: error: implicit declaration of function ‘ucl_parser_get_error’ [-Werror=implicit-function-declaration]
 3347 |    ucl_parser_get_error(parser));
      |    ^~~~~~~~~~~~~~~~~~~~
gitup.c:3346:19: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
 3346 |    "load_config: %s\n",
      |                  ~^
      |                   |
      |                   char *
      |                  %d
 3347 |    ucl_parser_get_error(parser));
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |    |
      |    int
gitup.c:3352:11: error: implicit declaration of function ‘ucl_parser_get_object’ [-Werror=implicit-function-declaration]
 3352 |  object = ucl_parser_get_object(parser);
      |           ^~~~~~~~~~~~~~~~~~~~~
gitup.c:3352:9: error: assignment to ‘int *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3352 |  object = ucl_parser_get_object(parser);
      |         ^
gitup.c:3355:18: error: assignment to ‘const int *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3355 |  while ((section = ucl_object_iterate_safe(it, true))) {
      |                  ^
gitup.c:3356:10: error: assignment to ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 3356 |   target = ucl_object_key(section);
      |          ^
gitup.c:3385:2: error: implicit declaration of function ‘ucl_object_unref’ [-Werror=implicit-function-declaration]
 3385 |  ucl_object_unref(object);
      |  ^~~~~~~~~~~~~~~~
gitup.c:3386:2: error: implicit declaration of function ‘ucl_parser_free’ [-Werror=implicit-function-declaration]
 3386 |  ucl_parser_free(parser);
      |  ^~~~~~~~~~~~~~~
gitup.c: In function ‘main’:
gitup.c:3726:4: error: conversion from ‘size_t’ {aka ‘long unsigned int’} to ‘int’ may change value [-Werror=conversion]
 3726 |    strlen(credentials));
      |    ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/ctype.h:100,
                 from gitup.c:41:
gitup.c:3797:32: error: array subscript has type ‘char’ [-Werror=char-subscripts]
 3797 |   if ((!isalpha(session.section[o])) && (!isdigit(session.section[o]))) {
      |                                ^
gitup.c:3797:66: error: array subscript has type ‘char’ [-Werror=char-subscripts]
 3797 |   if ((!isalpha(session.section[o])) && (!isdigit(session.section[o]))) {
      |                                                                  ^
gitup.c:3558:38: error: variable ‘pack_history_exists’ set but not used [-Werror=unused-but-set-variable]
 3558 |  bool      pack_data_exists = false, pack_history_exists = false;
      |                                      ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
0-wiz-0 commented 2 years ago

I see you committed more fixes. Except for the ucl stuff, there's now only:


gitup.c: In function ‘unpack_objects’:                                                                                                                                                       
gitup.c:2357:17: error: conversion to ‘long unsigned int’ from ‘__off_t’ {aka ‘long int’} may change the sign of the result [-Werror=sign-conversion]
 2357 |    cache_length += buffer_size;
      |                 ^~
gitup.c:2357:20: error: conversion to ‘__off_t’ {aka ‘long int’} from ‘long unsigned int’ may change the sign of the result [-Werror=sign-conversion]
 2357 |    cache_length += buffer_size;
      |                    ^~~~~~~~~~~
gitup.c: In function ‘apply_deltas’:
gitup.c:2456:12: error: variable ‘old_file_size’ set but not used [-Werror=unused-but-set-variable]
 2456 |  uint32_t  old_file_size, new_file_size, new_position = 0;
      |            ^~~~~~~~~~~~~

gitup.c: In function ‘main’:
gitup.c:3560:38: error: variable ‘pack_history_exists’ set but not used [-Werror=unused-but-set-variable]
 3560 |  bool      pack_data_exists = false, pack_history_exists;
      |                                      ^~~~~~~~~~~~~~~~~~~
michael-o commented 2 years ago

Obviously, it should support https://github.com/vstakhov/libucl as an alternative to privateucl.