texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Fix compiler warnings


From: Patrice Dumas
Subject: branch master updated: Fix compiler warnings
Date: Fri, 04 Oct 2024 06:17:32 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new c1f9be222f Fix compiler warnings
c1f9be222f is described below

commit c1f9be222f76b060b0fcba35aaa2bb4577fc5e26
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 11 16:36:22 2024 +0200

    Fix compiler warnings
    
    * tp/Texinfo/XS/convert/convert_html.c: put static before const in
    declarations.
    
    * tp/Texinfo/XS/convert/convert_html.c
    (html_cancel_pending_formatted_inline_content)
    (set_root_commands_targets_node_files),
    tp/Texinfo/XS/convert/get_html_perl_info.c
    (html_set_shared_conversion_state, html_get_shared_conversion_state),
    tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal),
    tp/Texinfo/XS/main/convert_utils.c (definition_arguments_content)
    (definition_category_tree, output_files_register_closed),
    tp/Texinfo/XS/main/manipulate_tree.c (remove_from_source_mark_list):
    modify code to remove useless conditions of positivity and negativity
    of size_t variables.
    
    * tp/Texinfo/XS/main/customization_options.c (copy_options_list):
    check if pointer is NULL, not if > 0.
    
    * tp/Texinfo/XS/main/convert_to_text.c (convert_def_line),
    tp/Texinfo/XS/parsetexi/counter.c (counter_reset),
    tp/Texinfo/XS/parsetexi/def.c (split_delimiters, split_def_args),
    tp/Texinfo/XS/parsetexi/indices.c (complete_indices),
    tp/Texinfo/XS/parsetexi/macro.c (handle_macro),
    tp/Texinfo/XS/parsetexi/parser.c (parse_texi): modify code to
    avoid uninitialized variable compiler warning.
    
    * tp/Texinfo/XS/main/manipulate_tree.c (copy_associated_info): add
    missing break.
    
    * tp/Texinfo/XS/main/manipulate_tree.c (copy_container_contents): fix
    new_command_element call order.
    
    * tp/Texinfo/XS/parsetexi/def.c (DEF_MAP, parse_def, def*_types): fix
    type, it is enum element_type.
---
 ChangeLog                                  | 39 ++++++++++++++++++++++++++++++
 tp/Texinfo/XS/convert/convert_html.c       | 17 +++++++------
 tp/Texinfo/XS/convert/get_html_perl_info.c |  4 +--
 tp/Texinfo/XS/main/convert_to_text.c       | 10 ++++----
 tp/Texinfo/XS/main/convert_utils.c         | 11 +++++----
 tp/Texinfo/XS/main/customization_options.c |  2 +-
 tp/Texinfo/XS/main/extra.c                 |  2 +-
 tp/Texinfo/XS/main/manipulate_tree.c       |  9 +++----
 tp/Texinfo/XS/parsetexi/counter.c          |  2 +-
 tp/Texinfo/XS/parsetexi/def.c              | 36 ++++++++++++---------------
 tp/Texinfo/XS/parsetexi/indices.c          | 13 ++++++++++
 tp/Texinfo/XS/parsetexi/macro.c            |  6 ++---
 tp/Texinfo/XS/parsetexi/parser.c           |  2 +-
 13 files changed, 100 insertions(+), 53 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3a86ce0ff3..892d387380 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,42 @@
+2024-08-11  Patrice Dumas  <pertusus@free.fr>
+
+       Fix compiler warnings
+
+       * tp/Texinfo/XS/convert/convert_html.c: put static before const in
+       declarations.
+
+       * tp/Texinfo/XS/convert/convert_html.c
+       (html_cancel_pending_formatted_inline_content)
+       (set_root_commands_targets_node_files),
+       tp/Texinfo/XS/convert/get_html_perl_info.c
+       (html_set_shared_conversion_state, html_get_shared_conversion_state),
+       tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal),
+       tp/Texinfo/XS/main/convert_utils.c (definition_arguments_content)
+       (definition_category_tree, output_files_register_closed),
+       tp/Texinfo/XS/main/manipulate_tree.c (remove_from_source_mark_list):
+       modify code to remove useless conditions of positivity and negativity
+       of size_t variables.
+
+       * tp/Texinfo/XS/main/customization_options.c (copy_options_list):
+       check if pointer is NULL, not if > 0.
+
+       * tp/Texinfo/XS/main/convert_to_text.c (convert_def_line),
+       tp/Texinfo/XS/parsetexi/counter.c (counter_reset),
+       tp/Texinfo/XS/parsetexi/def.c (split_delimiters, split_def_args),
+       tp/Texinfo/XS/parsetexi/indices.c (complete_indices),
+       tp/Texinfo/XS/parsetexi/macro.c (handle_macro),
+       tp/Texinfo/XS/parsetexi/parser.c (parse_texi): modify code to
+       avoid uninitialized variable compiler warning.
+
+       * tp/Texinfo/XS/main/manipulate_tree.c (copy_associated_info): add
+       missing break.
+
+       * tp/Texinfo/XS/main/manipulate_tree.c (copy_container_contents): fix
+       new_command_element call order.
+
+       * tp/Texinfo/XS/parsetexi/def.c (DEF_MAP, parse_def, def*_types): fix
+       type, it is enum element_type.
+
 2024-08-11  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init),
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 0ae4da1293..422e81a96a 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1218,14 +1218,16 @@ html_cancel_pending_formatted_inline_content (CONVERTER 
*self,
   HTML_INLINE_CONTENT_STACK *stack = &self->pending_inline_content;
   if (stack->top)
     {
-      size_t current_idx = stack->top - 1;
-      while (current_idx >= 0)
+      size_t current_position = stack->top;
+      size_t current_idx;
+      while (current_position > 0)
         {
+          current_idx = current_position - 1;
           if (!strcmp (stack->stack[current_idx].category, category))
             {
               char *inline_content = stack->stack[current_idx].string;
               free (stack->stack[current_idx].category);
-              if (current_idx < stack->top - 1)
+              if (current_position < stack->top)
                 {
                   memmove (&stack->stack[current_idx],
                            &stack->stack[current_idx+1],
@@ -2306,8 +2308,7 @@ set_root_commands_targets_node_files (CONVERTER *self)
         }
     }
 
-  if (self->document->sections_list
-      && self->document->sections_list->number >= 0)
+  if (self->document->sections_list)
     {
       const CONST_ELEMENT_LIST *sections_list = self->document->sections_list;
       int i;
@@ -9571,7 +9572,7 @@ convert_footnote_command (CONVERTER *self, const enum 
command_id cmd,
                     const HTML_ARGS_FORMATTED *args_formatted,
                     const char *content, TEXT *result)
 {
-  const static char *target_prefix = "t_f";
+  static const char *target_prefix = "t_f";
   char *footnote_mark;
   const char *footnote_id;
   const char *footnote_docid;
@@ -16612,7 +16613,7 @@ special_unit_body_formatting_external (CONVERTER *self,
                                        output_unit, result);
 }
 
-const static enum command_id simpletitle_cmds[] =
+static const enum command_id simpletitle_cmds[] =
  {CM_settitle, CM_shorttitlepage, 0};
 
 void
@@ -16634,7 +16635,7 @@ html_prepare_simpletitle (CONVERTER *self)
     }
 }
 
-const static enum command_id fulltitle_cmds[] =
+static const enum command_id fulltitle_cmds[] =
  {CM_settitle, CM_title, CM_shorttitlepage, CM_top, 0};
 
 
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 2dc460d11a..1ffae6c8d1 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -1800,7 +1800,7 @@ html_set_shared_conversion_state (CONVERTER *converter, 
SV *converter_in,
               LISTOFFLOATS_TYPE *float_types = &listoffloats->float_types[i];
               if (!strcmp (float_types->type, type))
                 {
-                  if (float_types->float_list.number >= 0)
+                  if (float_types->float_list.number > 0)
                     {
                       int *formatted_listoffloats_nr
                         = &converter->shared_conversion_state
@@ -1887,7 +1887,7 @@ html_get_shared_conversion_state (CONVERTER *converter, 
SV *converter_in,
               const LISTOFFLOATS_TYPE *float_types = 
&listoffloats->float_types[i];
               if (!strcmp (float_types->type, type))
                 {
-                  if (float_types->float_list.number >= 0)
+                  if (float_types->float_list.number > 0)
                     {
                       return newSViv (converter->shared_conversion_state
                                        .formatted_listoffloats_nr[i]);
diff --git a/tp/Texinfo/XS/main/convert_to_text.c 
b/tp/Texinfo/XS/main/convert_to_text.c
index 5a9f49cd4c..b84f6b49ff 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -454,8 +454,8 @@ convert_def_line(const ELEMENT *element, TEXT_OPTIONS 
*text_options,
       ELEMENT *converted_element = new_element (ET_NONE);
       ELEMENT *text_colon = new_text_element (ET_normal_text);
       ELEMENT *text_eol = new_text_element (ET_normal_text);
-      ELEMENT *type_text_space;
-      ELEMENT *args_text_space;
+      ELEMENT *type_text_space = 0;
+      ELEMENT *args_text_space = 0;
       add_to_contents_as_array (converted_element,
                                 parsed_definition_category);
       text_append (text_colon->e.text, ": ");
@@ -488,11 +488,11 @@ convert_def_line(const ELEMENT *element, TEXT_OPTIONS 
*text_options,
       destroy_element (text_colon);
       destroy_element_and_children (parsed_definition_category);
       destroy_element (text_eol);
-      if (parsed_def->type)
+      if (type_text_space)
         {
           destroy_element (type_text_space);
         }
-      if (parsed_def->args)
+      if (args_text_space)
         {
           destroy_element (args_text_space);
         }
@@ -865,7 +865,7 @@ convert_to_text_internal (const ELEMENT *element, 
TEXT_OPTIONS *text_options,
                || data_cmd == CM_float
                || data_cmd == CM_cartouche)
         {
-          if (element->e.c->args.number >= 0)
+          if (element->e.c->args.number > 0)
             {
               int i;
               TEXT args_line;
diff --git a/tp/Texinfo/XS/main/convert_utils.c 
b/tp/Texinfo/XS/main/convert_utils.c
index ad3b90abb0..db4eb4d3f7 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -470,7 +470,8 @@ definition_arguments_content (const ELEMENT *element)
 {
   PARSED_DEF *result = malloc (sizeof (PARSED_DEF));
   memset (result, 0, sizeof (PARSED_DEF));
-  if (element->e.c->args.number >= 0)
+  /* this condition is most probably always true */
+  if (element->e.c->args.number > 0)
     {
       int i;
       const ELEMENT *def_line = element->e.c->args.list[0];
@@ -526,7 +527,7 @@ definition_category_tree (OPTIONS * options, const ELEMENT 
*current)
   ELEMENT *class_copy;
   char *def_command;
 
-  if (current->e.c->args.number >= 0)
+  if (current->e.c->args.number > 0)
     {
       int i;
       const ELEMENT *def_line = current->e.c->args.list[0];
@@ -825,16 +826,16 @@ output_files_register_closed (OUTPUT_FILES_INFORMATION 
*self,
   if (unclosed_files_nr)
     {
       size_t j;
-      for (j = unclosed_files_nr -1; j >= 0; j--)
+      for (j = unclosed_files_nr; j > 0; j--)
         {
-          FILE_STREAM *file_stream = &self->unclosed_files.list[j];
+          FILE_STREAM *file_stream = &self->unclosed_files.list[j -1];
           if (file_stream->file_path)
             {
               if (!strcmp (file_path, file_stream->file_path))
                 {
                   free (file_stream->file_path);
                   file_stream->file_path = 0;
-                  if (j == unclosed_files_nr -1)
+                  if (j == unclosed_files_nr)
                     {
                       self->unclosed_files.number--;
                     }
diff --git a/tp/Texinfo/XS/main/customization_options.c 
b/tp/Texinfo/XS/main/customization_options.c
index 65af7ced63..13955b9562 100644
--- a/tp/Texinfo/XS/main/customization_options.c
+++ b/tp/Texinfo/XS/main/customization_options.c
@@ -512,7 +512,7 @@ copy_options_list (OPTIONS_LIST *options_list,
 {
   size_t i;
 
-  if (options_src > 0)
+  if (options_src)
     {
       for (i = 0; i < options_src->number; i++)
         add_option_copy (options_list, sorted_options, options_src->list[i]);
diff --git a/tp/Texinfo/XS/main/extra.c b/tp/Texinfo/XS/main/extra.c
index 46172127b7..3b9880f59a 100644
--- a/tp/Texinfo/XS/main/extra.c
+++ b/tp/Texinfo/XS/main/extra.c
@@ -93,7 +93,7 @@ add_extra_element_oot (ELEMENT *e, enum ai_key_name key, 
ELEMENT *value)
 /* Add an extra key that is a reference to elements elsewhere in the tree,
    in general in the contents array of another element (for example,
    'node_content' on a node direction element contents).
-   Similar to extra_contents, but passed to perl as an element with
+   Similar to extra_contents, but passed to Perl as an element with
    contents.
  */
 void
diff --git a/tp/Texinfo/XS/main/manipulate_tree.c 
b/tp/Texinfo/XS/main/manipulate_tree.c
index b0c5e47852..28236abad5 100644
--- a/tp/Texinfo/XS/main/manipulate_tree.c
+++ b/tp/Texinfo/XS/main/manipulate_tree.c
@@ -71,6 +71,7 @@ copy_associated_info (ASSOCIATED_INFO *info, ASSOCIATED_INFO* 
new_info)
               = get_associated_info_key (new_info, key, k_ref->type);
             k->k.const_element = copy;
           }
+          break;
         case extra_element_oot:
           {
             ELEMENT *f = k_ref->k.element;
@@ -401,8 +402,7 @@ copy_container_contents (const ELEMENT *container)
 {
   ELEMENT *result;
   if (container->e.c->cmd)
-    result = new_command_element (container->e.c->cmd,
-                                  container->type);
+    result = new_command_element (container->type, container->e.c->cmd);
   else
     result = new_element (container->type);
 
@@ -444,10 +444,7 @@ remove_from_source_mark_list (SOURCE_MARK_LIST *list, 
size_t where)
 {
   SOURCE_MARK *removed;
 
-  if (where < 0)
-    where = list->number + where;
-
-  if (where < 0 || where > list->number)
+  if (where > list->number)
     fatal ("source marks list index out of bounds");
 
   removed = list->list[where];
diff --git a/tp/Texinfo/XS/parsetexi/counter.c 
b/tp/Texinfo/XS/parsetexi/counter.c
index 49f543c8a8..a0467eada0 100644
--- a/tp/Texinfo/XS/parsetexi/counter.c
+++ b/tp/Texinfo/XS/parsetexi/counter.c
@@ -140,7 +140,7 @@ counter_reset (COUNTER *c, const char* not_empty_message)
           ELEMENT *e = c->elts[i];
           char *element_string = print_element_debug (e, 0);
            */
-          char *element_string = 0;
+          char *element_string = strdup ("");
           fprintf (stderr, "  %d: %d, %s\n", i, c->values[i],
                                              element_string);
           free (element_string);
diff --git a/tp/Texinfo/XS/parsetexi/def.c b/tp/Texinfo/XS/parsetexi/def.c
index 142a1af258..f71d1ce595 100644
--- a/tp/Texinfo/XS/parsetexi/def.c
+++ b/tp/Texinfo/XS/parsetexi/def.c
@@ -160,7 +160,7 @@ next_bracketed_or_word_agg (ELEMENT *current, int *i)
 
 typedef struct {
     enum command_id command;
-    enum command_id *argument_types;
+    enum element_type *argument_types;
 } DEF_MAP;
 
   /*
@@ -171,16 +171,16 @@ typedef struct {
      NAME - name of entity being documented
      ARGUMENTS - arguments to a function or macro                  */
 
-enum command_id defline_types[] = {ET_def_category, ET_def_name, ET_def_arg, 
0};
-enum command_id deftypeline_types[] = {ET_def_category, ET_def_type, 
ET_def_name, ET_def_typearg, 0};
-enum command_id defvr_types[] = {ET_def_category, ET_def_name, 0};
-enum command_id deftypefn_types[] = {ET_def_category, ET_def_type, 
ET_def_name, ET_def_typearg, 0};
-enum command_id deftypeop_types[] = {ET_def_category, ET_def_class , 
ET_def_type, ET_def_name, ET_def_typearg, 0};
-enum command_id deftypevr_types[] = {ET_def_category, ET_def_type, 
ET_def_name, 0};
-enum command_id defcv_types[] = {ET_def_category, ET_def_class , ET_def_name, 
0};
-enum command_id deftypecv_types[] = {ET_def_category, ET_def_class , 
ET_def_type, ET_def_name, 0};
-enum command_id defop_types[] = {ET_def_category, ET_def_class , ET_def_name, 
ET_def_arg, 0};
-enum command_id deftp_types[] = {ET_def_category, ET_def_name, ET_def_typearg, 
0};
+enum element_type defline_types[] = {ET_def_category, ET_def_name, ET_def_arg, 
0};
+enum element_type deftypeline_types[] = {ET_def_category, ET_def_type, 
ET_def_name, ET_def_typearg, 0};
+enum element_type defvr_types[] = {ET_def_category, ET_def_name, 0};
+enum element_type deftypefn_types[] = {ET_def_category, ET_def_type, 
ET_def_name, ET_def_typearg, 0};
+enum element_type deftypeop_types[] = {ET_def_category, ET_def_class , 
ET_def_type, ET_def_name, ET_def_typearg, 0};
+enum element_type deftypevr_types[] = {ET_def_category, ET_def_type, 
ET_def_name, 0};
+enum element_type defcv_types[] = {ET_def_category, ET_def_class , 
ET_def_name, 0};
+enum element_type deftypecv_types[] = {ET_def_category, ET_def_class , 
ET_def_type, ET_def_name, 0};
+enum element_type defop_types[] = {ET_def_category, ET_def_class , 
ET_def_name, ET_def_arg, 0};
+enum element_type deftp_types[] = {ET_def_category, ET_def_name, 
ET_def_typearg, 0};
 
 DEF_MAP def_maps[] = {
   CM_defline, defline_types,
@@ -211,8 +211,8 @@ split_delimiters (ELEMENT *current, int starting_idx)
       int len;
       /* count UTF-8 encoded Unicode characters for source marks locations */
       uint8_t *u8_text = 0;
-      size_t current_position;
-      uint8_t *u8_p;
+      size_t current_position = 0;
+      uint8_t *u8_p = 0;
       size_t u8_len;
 
       if (e->type == ET_spaces || e->type == ET_bracketed_arg)
@@ -232,8 +232,6 @@ split_delimiters (ELEMENT *current, int starting_idx)
         {
           u8_text = utf8_from_string (p);
           u8_p = u8_text;
-
-          current_position = 0;
         }
 
       while (1)
@@ -300,8 +298,8 @@ split_def_args (ELEMENT *current, int starting_idx)
       int len;
       /* count UTF-8 encoded Unicode characters for source marks locations */
       uint8_t *u8_text = 0;
-      size_t current_position;
-      uint8_t *u8_p;
+      size_t current_position = 0;
+      uint8_t *u8_p = 0;
       size_t u8_len;
 
       if (e->type == ET_bracketed_arg)
@@ -319,8 +317,6 @@ split_def_args (ELEMENT *current, int starting_idx)
         {
           u8_text = utf8_from_string (p);
           u8_p = u8_text;
-
-          current_position = 0;
         }
 
       while (1)
@@ -364,7 +360,7 @@ parse_def (enum command_id command, ELEMENT *current)
   int i, i_def;
   int arg_types_nr;
   ELEMENT *e, *e1;
-  enum command_id *arguments_types_list;
+  enum element_type *arguments_types_list;
   int inserted_category = 0;
 
   split_def_args (current, contents_idx);
diff --git a/tp/Texinfo/XS/parsetexi/indices.c 
b/tp/Texinfo/XS/parsetexi/indices.c
index bcf164075d..ea222cb9df 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -466,6 +466,19 @@ complete_indices (DOCUMENT *document, int debug_level)
 
                           text_append (text_element->e.text, " of ");
                         }
+             /* should not be possible, still considered for more robust code 
*/
+                      else
+                        {
+                          char *msg;
+                          /* set index_entry to avalue to avoid a compiler 
warning
+                             on uninitialized value.  Incorrect for the code 
below, but
+                             we do not care as fatal is called. */
+                          index_entry = 0;
+                          xasprintf (&msg, "BUG: unexpected def command with 
name"
+                                   "and class: %s", builtin_command_name 
(def_command));
+                          fatal (msg);
+                          free (msg);
+                        }
                       destroy_named_string_element_list (substrings);
 
                       add_to_element_contents
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index ea677f8d7c..ef8e7ffb0d 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -826,7 +826,7 @@ handle_macro (ELEMENT *current, const char **line_inout, 
enum command_id cmd)
         {
           if (macro->e.c->cmd == CM_macro)
             macro_call_element = new_element (ET_macro_call);
-          else if (macro->e.c->cmd == CM_rmacro)
+          else /* macro->e.c->cmd == CM_rmacro */
             macro_call_element = new_element (ET_rmacro_call);
           if (p - line > 0)
             {
@@ -850,7 +850,7 @@ handle_macro (ELEMENT *current, const char **line_inout, 
enum command_id cmd)
 
           if (macro->e.c->cmd == CM_macro)
             macro_call_element = new_element (ET_macro_call);
-          else if (macro->e.c->cmd == CM_rmacro)
+          else /* macro->e.c->cmd == CM_rmacro */
             macro_call_element = new_element (ET_rmacro_call);
         }
       else
@@ -858,7 +858,7 @@ handle_macro (ELEMENT *current, const char **line_inout, 
enum command_id cmd)
           ELEMENT *arg_elt = new_element (ET_line_arg);
           if (macro->e.c->cmd == CM_macro)
             macro_call_element = new_element (ET_macro_call_line);
-          else if (macro->e.c->cmd == CM_rmacro)
+          else /* macro->e.c->cmd == CM_rmacro */
             macro_call_element = new_element (ET_rmacro_call_line);
           add_to_element_args (macro_call_element, arg_elt);
 
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index e64c453de0..b2bd9101fa 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2665,7 +2665,7 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
   ELEMENT *current = current_elt;
   static char *allocated_line;
   const char *line;
-  int status;
+  int status = STILL_MORE_TO_PROCESS;
   DOCUMENT *document = parsed_document;
   enum context top_context;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]