poke-devel
[Top][All Lists]
Advanced

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

[PATCH 2/4] maint: Fix syntax-check


From: Eric Blake
Subject: [PATCH 2/4] maint: Fix syntax-check
Date: Tue, 25 Feb 2020 22:11:50 -0600

Mostly whitespace, but one case of unchecked strncpy that I'd
rather exempt for now than audit for the best way to rewrite it.

* .x-sc_prohibit_strncpy: Exempt pk-repl.c.
* etc/poke.g4 (expression): Whitespace cleanups.
* doc/poke.texi (String Concatenation): Likewise.
* src/ios-dev-file.c (ios_dev_file_close): Likewise.
* src/ios-dev-mem.c (ios_dev_mem_getc): Likewise.
* src/ios.c: Likewise.
* src/pk-hserver.c: Likewise.
* src/pk-ios.c: Likewise.
* src/pk-set.c: Likewise.
* src/pkl-ast.c: Likewise.
* src/pkl-ast.h: Likewise.
* src/pkl-fold.c: Likewise.
* src/pkl-insn.def: Likewise.
* src/pkl-tab.y: Likewise.
* src/pkl-typify.c: Likewise.
* src/pvm.jitter: Likewise.
* testsuite/poke.pkl/structs-diag-1.pk: Likewise.
---
 .x-sc_prohibit_strncpy               |  1 +
 ChangeLog                            | 21 +++++++++++++++++++++
 doc/poke.texi                        |  2 +-
 etc/poke.g4                          |  4 ++--
 src/ios-dev-file.c                   |  2 +-
 src/ios-dev-mem.c                    |  2 +-
 src/ios.c                            | 14 +++++++-------
 src/pk-hserver.c                     | 16 ++++++++--------
 src/pk-ios.c                         | 24 ++++++++++++------------
 src/pk-set.c                         | 16 ++++++++--------
 src/pkl-ast.c                        |  4 ++--
 src/pkl-ast.h                        |  2 +-
 src/pkl-fold.c                       |  8 ++++----
 src/pkl-insn.def                     |  2 +-
 src/pkl-tab.y                        |  2 +-
 src/pkl-typify.c                     |  2 +-
 src/pvm.jitter                       |  4 ++--
 testsuite/poke.pkl/structs-diag-1.pk |  2 +-
 18 files changed, 75 insertions(+), 53 deletions(-)

diff --git a/.x-sc_prohibit_strncpy b/.x-sc_prohibit_strncpy
index 5cd5d692..a0ed4b89 100644
--- a/.x-sc_prohibit_strncpy
+++ b/.x-sc_prohibit_strncpy
@@ -1,2 +1,3 @@
 src/pk-cmd.c
+src/pk-repl.c
 src/pvm.jitter
diff --git a/ChangeLog b/ChangeLog
index 5797cb0f..1323835d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2020-02-25  Eric Blake  <address@hidden>
+
+       maint: Fix syntax-check
+       * .x-sc_prohibit_strncpy: Exempt pk-repl.c.
+       * etc/poke.g4 (expression): Whitespace cleanups.
+       * doc/poke.texi (String Concatenation): Likewise.
+       * src/ios-dev-file.c (ios_dev_file_close): Likewise.
+       * src/ios-dev-mem.c (ios_dev_mem_getc): Likewise.
+       * src/ios.c: Likewise.
+       * src/pk-hserver.c: Likewise.
+       * src/pk-ios.c: Likewise.
+       * src/pk-set.c: Likewise.
+       * src/pkl-ast.c: Likewise.
+       * src/pkl-ast.h: Likewise.
+       * src/pkl-fold.c: Likewise.
+       * src/pkl-insn.def: Likewise.
+       * src/pkl-tab.y: Likewise.
+       * src/pkl-typify.c: Likewise.
+       * src/pvm.jitter: Likewise.
+       * testsuite/poke.pkl/structs-diag-1.pk: Likewise.
+
 2020-02-25  Eric Blake  <address@hidden>

        maint: Saner diff output
diff --git a/doc/poke.texi b/doc/poke.texi
index 24aa556c..5b729262 100644
--- a/doc/poke.texi
+++ b/doc/poke.texi
@@ -1982,7 +1982,7 @@ String Concatenation
 @example
 defun make_empty_string = (int length) string:
 @{
-   return " " * length;  
+   return " " * length;
 @}
 @end example

diff --git a/etc/poke.g4 b/etc/poke.g4
index c90445b4..23cd046d 100644
--- a/etc/poke.g4
+++ b/etc/poke.g4
@@ -116,7 +116,7 @@ expression:
     | TYPENAME '{' struct_field_list '}'
     | UNIT
     | expression UNIT
-       | struct
+       | struct
     /* The next rule is bconc, but we cannot use the bconc rule
        because that introduces indirect left-recursivity that cannot
        be handled by antlr4.  */
@@ -273,7 +273,7 @@ struct_type_specifier:

 struct_or_union:
         'struct'
-       | 'union'       
+       | 'union'
     ;

 struct_type_pinned:
diff --git a/src/ios-dev-file.c b/src/ios-dev-file.c
index a8d83832..4003cf9c 100644
--- a/src/ios-dev-file.c
+++ b/src/ios-dev-file.c
@@ -116,7 +116,7 @@ ios_dev_file_close (void *iod)
     perror (fio->filename);
   free (fio->filename);
   free (fio);
-  
+
   return 1;
 }

diff --git a/src/ios-dev-mem.c b/src/ios-dev-mem.c
index 3a6ffb3f..098a327f 100644
--- a/src/ios-dev-mem.c
+++ b/src/ios-dev-mem.c
@@ -86,7 +86,7 @@ ios_dev_mem_getc (void *iod)

   if (mio->cur >= mio->size)
     return IOD_EOF;
-  
+
   return mio->pointer[mio->cur++];
 }

diff --git a/src/ios.c b/src/ios.c
index 75eacdaf..2340bc88 100644
--- a/src/ios.c
+++ b/src/ios.c
@@ -699,7 +699,7 @@ ios_read_int (ios io, ios_off offset, int flags,
 {
   /* Apply the IOS bias.  */
   offset += ios_get_bias (io);
-  
+
   /* We always need to start reading from offset / 8  */
   if (io->dev_if->seek (io->dev, offset / 8, IOD_SEEK_SET) == -1)
     return IOS_EIOFF;
@@ -933,16 +933,16 @@ ios_read_string (ios io, ios_off offset, int flags, char 
**value)
       /* This is the fast case: the string is aligned to a byte
          boundary.  We just read bytes from the IOD until either EOF
          or a NULL byte.  */
-      
+
       if (io->dev_if->seek (io->dev, offset / 8, IOD_SEEK_SET)
           == -1)
         return IOS_EIOFF;
-      
+
       do
         {
           if (i % 128 == 0)
             str = xrealloc (str, i + 128 * sizeof (char));
-          
+
           c = io->dev_if->get_c (io->dev);
           if (c == IOD_EOF)
             return IOS_EIOFF;
@@ -961,7 +961,7 @@ ios_read_string (ios io, ios_off offset, int flags, char 
**value)
         {
           int ret;
           uint64_t abyte;
-          
+
           if (i % 128 == 0)
             str = xrealloc (str, i + 128 * sizeof (char));

@@ -1572,11 +1572,11 @@ ios_write_string (ios io, ios_off offset, int flags,
     {
       /* This is the fast case: we want to write a string at a
          byte-boundary.  Just write the bytes to the IOD.  */
-      
+
       if (io->dev_if->seek (io->dev, offset / 8, IOD_SEEK_SET)
           == -1)
         return IOS_EIOFF;
-      
+
       p = value;
       do
         {
diff --git a/src/pk-hserver.c b/src/pk-hserver.c
index 8c05b362..d9901b44 100644
--- a/src/pk-hserver.c
+++ b/src/pk-hserver.c
@@ -81,7 +81,7 @@ make_socket (uint16_t port)
 {
   int sock;
   struct sockaddr_in name;
-  
+
   /* Create the socket. */
   sock = socket (PF_INET, SOCK_STREAM, 0);
   if (sock < 0)
@@ -125,7 +125,7 @@ read_from_client (int filedes)
 {
   char buffer[MAXMSG];
   int nbytes;
-  
+
   nbytes = read (filedes, buffer, MAXMSG);
   if (nbytes < 0)
     {
@@ -144,7 +144,7 @@ read_from_client (int filedes)

       /* Remove the newline at the end.  */
       buffer[nbytes-1] = '\0';
-      
+
       /* The format of the payload is:
          [0-9]+/{e,i}/.*  */

@@ -154,10 +154,10 @@ read_from_client (int filedes)
           printf ("PARSING INT\n");
           return 0;
         }
-        
+
       if (!hserver_tokens[token])
         return 0;
-      
+
       if (*p != '/')
         return 0;
       p++;
@@ -170,7 +170,7 @@ read_from_client (int filedes)
       if (*p != '/')
         return 0;
       p++;
-      
+
       switch (cmd)
         {
         case 'e':
@@ -332,7 +332,7 @@ pk_hserver_make_hyperlink (char type,
   int token;
   char *str, token_str[128], type_str[2];
   char hostname[128];
-  
+
   assert (type == 'i' || type == 'e');
   type_str[0] = type;
   type_str[1] = '\0';
@@ -340,7 +340,7 @@ pk_hserver_make_hyperlink (char type,
   /* XXX: check for maximum length 2048.  */
   token = pk_hserver_get_token ();
   sprintf (token_str, "%d", token);
-  
+
   if (gethostname (hostname, 128) != 0)
     {
       perror ("gethostname");
diff --git a/src/pk-ios.c b/src/pk-ios.c
index f98c8808..08ca89f8 100644
--- a/src/pk-ios.c
+++ b/src/pk-ios.c
@@ -109,21 +109,21 @@ pk_cmd_file (int argc, struct pk_cmd_arg argv[], uint64_t 
uflags)
   /* Create a new IO space.  */
   const char *arg_str = PK_CMD_ARG_STR (argv[0]);
   const char *filename = arg_str;
-  
+
   if (access (filename, R_OK) != 0)
     {
       char *why = strerror (errno);
       pk_printf (_("%s: file cannot be read: %s\n"), arg_str, why);
       return 0;
     }
-  
+
   if (ios_search (filename) != NULL)
     {
       printf (_("File %s already opened.  Use `.ios #N' to switch.\n"),
               filename);
       return 0;
     }
-  
+
   errno = 0;
   if (IOS_ERROR == ios_open (filename, 0, 1))
     {
@@ -188,7 +188,7 @@ print_info_ios (ios io, void *data)
   mode[0] = flags & IOS_F_READ ? 'r' : ' ';
   mode[1] = flags & IOS_F_WRITE ? 'w' : ' ';
   mode[2] = '\0';
-  
+
   pk_printf ("%s#%d\t%s\t",
              io == ios_cur () ? "* " : "  ",
              ios_get_id (io),
@@ -198,15 +198,15 @@ print_info_ios (ios io, void *data)
   {
     char *cmd;
     char *hyperlink;
-    
+
     asprintf (&cmd, "0x%08jx#b", ios_tell (io));
     hyperlink = pk_hserver_make_hyperlink ('i', cmd);
     free (cmd);
-    
+
     pk_term_hyperlink (hyperlink, NULL);
     pk_printf ("0x%08jx#b", ios_tell (io));
     pk_term_end_hyperlink ();
-    
+
     free (hyperlink);
   }
 #else
@@ -218,21 +218,21 @@ print_info_ios (ios io, void *data)
   {
     char *cmd;
     char *hyperlink;
-    
+
     asprintf (&cmd, ".file #%d", ios_get_id (io));
     hyperlink = pk_hserver_make_hyperlink ('e', cmd);
     free (cmd);
-    
+
     pk_term_hyperlink (hyperlink, NULL);
     pk_puts (ios_handler (io));
     pk_term_end_hyperlink ();
-    
+
     free (hyperlink);
   }
 #else
   pk_puts (ios_handler (io));
 #endif
-  
+
   pk_puts ("\n");
 }

@@ -299,7 +299,7 @@ pk_cmd_mem (int argc, struct pk_cmd_arg argv[], uint64_t 
uflags)

   assert (argc == 1);
   assert (PK_CMD_ARG_TYPE (argv[0]) == PK_CMD_ARG_STR);
-  
+
   /* Create a new memory IO space.  */
   const char *arg_str = PK_CMD_ARG_STR (argv[0]);
   char *mem_name = xmalloc (strlen (arg_str) + 2 + 1);
diff --git a/src/pk-set.c b/src/pk-set.c
index 2d51b852..fbad933d 100644
--- a/src/pk-set.c
+++ b/src/pk-set.c
@@ -52,10 +52,10 @@ pk_cmd_set_obase (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
           pk_puts ("obase should be one of 2, 8, 10 or 16.\n");
           return 0;
         }
-      
+
       poke_obase = base;
     }
-  
+
   return 1;
 }

@@ -233,7 +233,7 @@ pk_cmd_set_oacutoff (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
   else
     {
       int cutoff = PK_CMD_ARG_INT (argv[0]);
-      
+
       if (cutoff < 0 || cutoff > 15)
         {
           pk_term_class ("error");
@@ -242,10 +242,10 @@ pk_cmd_set_oacutoff (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
           pk_puts (_(" cutoff should be between 0 and 15.\n"));
           return 0;
         }
-      
+
       pvm_set_oacutoff (poke_vm, cutoff);
     }
-  
+
   return 1;
 }

@@ -261,7 +261,7 @@ pk_cmd_set_odepth (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
   else
     {
       int odepth = PK_CMD_ARG_INT (argv[0]);
-      
+
       if (odepth < 0 || odepth > 15)
         {
           pk_term_class ("error");
@@ -270,10 +270,10 @@ pk_cmd_set_odepth (int argc, struct pk_cmd_arg argv[], 
uint64_t uflags)
           pk_puts (_(" odepth should be between 0 and 15.\n"));
           return 0;
         }
-      
+
       pvm_set_odepth (poke_vm, odepth);
     }
-  
+
   return 1;
 }

diff --git a/src/pkl-ast.c b/src/pkl-ast.c
index 9264fc30..bfbcba17 100644
--- a/src/pkl-ast.c
+++ b/src/pkl-ast.c
@@ -659,7 +659,7 @@ pkl_struct_type_traverse (pkl_ast_node type, const char 
*path)
         {
           if (PKL_AST_CODE (t) != PKL_AST_STRUCT_TYPE_FIELD)
             continue;
-      
+
           ename = PKL_AST_STRUCT_TYPE_FIELD_NAME (t);
           etype = PKL_AST_STRUCT_TYPE_FIELD_TYPE (t);

@@ -2323,7 +2323,7 @@ pkl_ast_lvalue_p (pkl_ast_node node)

         if (PKL_AST_TYPE_CODE (entity_type) == PKL_TYPE_ARRAY)
           return pkl_ast_lvalue_p (entity);
-        
+
         break;
       }
     case PKL_AST_EXP:
diff --git a/src/pkl-ast.h b/src/pkl-ast.h
index 5cab2814..c70e9206 100644
--- a/src/pkl-ast.h
+++ b/src/pkl-ast.h
@@ -1527,7 +1527,7 @@ pkl_ast_node pkl_ast_make_print_stmt (pkl_ast ast,

 #define PKL_AST_PRINT_MODE_FLAT 0
 #define PKL_AST_PRINT_MODE_TREE 1
-  
+
 struct pkl_ast_print_stmt_arg
 {
   struct pkl_ast_common common;
diff --git a/src/pkl-fold.c b/src/pkl-fold.c
index aa7f7ad7..4890d78a 100644
--- a/src/pkl-fold.c
+++ b/src/pkl-fold.c
@@ -861,7 +861,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_fold_ps_cond_exp)
         = (PKL_AST_INTEGER_VALUE (cond)
            ? PKL_AST_COND_EXP_THENEXP (cond_exp)
            : PKL_AST_COND_EXP_ELSEEXP (cond_exp));
-      
+
       t = PKL_PASS_NODE;
       PKL_PASS_NODE = ASTREF (replacement_node);
       pkl_ast_node_free (t);
@@ -882,7 +882,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_fold_ps_indexer)
   if (PKL_AST_CODE (index) == PKL_AST_INTEGER)
     {
       int64_t index_value = PKL_AST_INTEGER_VALUE (index);
-      
+
       switch (PKL_AST_CODE (container))
         {
         case PKL_AST_STRING:
@@ -911,7 +911,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_fold_ps_indexer)

             t = PKL_PASS_NODE;
             PKL_PASS_NODE = ASTREF (new);
-            pkl_ast_node_free (t);                                       
+            pkl_ast_node_free (t);
             break;
           }
         case PKL_AST_ARRAY:
@@ -927,7 +927,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_fold_ps_indexer)
                 pkl_ast_node initializer_index
                   = PKL_AST_ARRAY_INITIALIZER_INDEX (t);
                 uint64_t initializer_index_value;
-                
+
                 assert (PKL_AST_CODE (initializer_index) == PKL_AST_INTEGER);
                 initializer_index_value
                   = PKL_AST_INTEGER_VALUE (initializer_index);
diff --git a/src/pkl-insn.def b/src/pkl-insn.def
index 83b0daaf..8fb5ac49 100644
--- a/src/pkl-insn.def
+++ b/src/pkl-insn.def
@@ -381,7 +381,7 @@ PKL_DEF_INSN (PKL_INSN_CLOSE, "", "close")
 PKL_DEF_INSN (PKL_INSN_IOSIZE, "", "iosize")
 PKL_DEF_INSN (PKL_INSN_IOGETB, "", "iogetb")
 PKL_DEF_INSN (PKL_INSN_IOSETB, "", "iosetb")
-  
+
 /* VM instructions.  */

 PKL_DEF_INSN (PKL_INSN_CANARY, "", "canary")
diff --git a/src/pkl-tab.y b/src/pkl-tab.y
index 52fa7be9..d06500d7 100644
--- a/src/pkl-tab.y
+++ b/src/pkl-tab.y
@@ -254,7 +254,7 @@ load_module (struct pkl_parser *parser,
   fclose (fd);
   return 0;
 }
- 
+
 %}

 %union {
diff --git a/src/pkl-typify.c b/src/pkl-typify.c
index 3bc6fe46..be8ea5e9 100644
--- a/src/pkl-typify.c
+++ b/src/pkl-typify.c
@@ -2395,7 +2395,7 @@ struct pkl_phase pkl_phase_typify1 =
    PKL_PHASE_PS_HANDLER (PKL_AST_IF_STMT, pkl_typify1_ps_if_stmt),
    PKL_PHASE_PS_HANDLER (PKL_AST_COND_EXP, pkl_typify1_ps_cond_exp),
    PKL_PHASE_PS_HANDLER (PKL_AST_ASS_STMT, pkl_typify1_ps_ass_stmt),
-   
+
    PKL_PHASE_PS_OP_HANDLER (PKL_AST_OP_SIZEOF, pkl_typify1_ps_op_sizeof),
    PKL_PHASE_PS_OP_HANDLER (PKL_AST_OP_NOT, pkl_typify1_ps_op_not),
    PKL_PHASE_PS_OP_HANDLER (PKL_AST_OP_EQ, pkl_typify1_ps_op_rela),
diff --git a/src/pvm.jitter b/src/pvm.jitter
index d2f4473d..aed38b73 100644
--- a/src/pvm.jitter
+++ b/src/pvm.jitter
@@ -820,7 +820,7 @@ instruction iosize ()

     if (io == NULL)
       PVM_RAISE (PVM_E_NO_IOS);
-      
+
     JITTER_PUSH_STACK (pvm_make_offset (pvm_make_ulong (ios_size (io), 64),
                                         pvm_make_ulong (1, 64)));
   end
@@ -846,7 +846,7 @@ instruction iogetb ()

     if (io == NULL)
       PVM_RAISE (PVM_E_NO_IOS);
-      
+
     JITTER_PUSH_STACK (pvm_make_offset (pvm_make_ulong (ios_get_bias (io), 64),
                                         pvm_make_ulong (1, 64)));
   end
diff --git a/testsuite/poke.pkl/structs-diag-1.pk 
b/testsuite/poke.pkl/structs-diag-1.pk
index 379bc7cf..1cef9692 100644
--- a/testsuite/poke.pkl/structs-diag-1.pk
+++ b/testsuite/poke.pkl/structs-diag-1.pk
@@ -4,5 +4,5 @@ defvar s = struct
            {
              a = 10, /* { dg-error "duplicated" } */
              b = 20,
-             a = 30 
+             a = 30
            };
-- 
2.24.1




reply via email to

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