src/language/stats/glm.c: Fix compiler warnings
[pspp] / src / language / stats / glm.c
index 51232fe160bcd5f64bfd39423ada691d627ee9ed..a6898502708506e7ebc5be5ca76254a4424d8a73 100644 (file)
@@ -262,19 +262,13 @@ cmd_glm (struct lexer *lexer, struct dataset *ds)
              goto error;
            }
 
-         if (! lex_force_int (lexer))
+         if (!lex_force_int_range (lexer, "SSTYPE", 1, 3))
            {
              lex_error (lexer, NULL);
              goto error;
            }
 
          glm.ss_type = lex_integer (lexer);
-         if (1 > glm.ss_type  ||  3 < glm.ss_type)
-           {
-             msg (ME, _("Only types 1, 2 & 3 sums of squares are currently implemented"));
-             goto error;
-           }
-
          lex_get (lexer);
 
          if (! lex_force_match (lexer, T_RPAREN))
@@ -392,8 +386,8 @@ ssq_type1 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd)
   const gsl_matrix *cm = covariance_calculate_unnormalized (cov);
   size_t i;
   size_t k;
-  bool *model_dropped = xcalloc (covariance_dim (cov), sizeof (*model_dropped));
-  bool *submodel_dropped = xcalloc (covariance_dim (cov), sizeof (*submodel_dropped));
+  bool *model_dropped = XCALLOC (covariance_dim (cov), bool);
+  bool *submodel_dropped = XCALLOC (covariance_dim (cov), bool);
   const struct categoricals *cats = covariance_get_categoricals (cov);
 
   size_t n_dropped_model = 0;
@@ -461,8 +455,8 @@ ssq_type2 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd)
   const gsl_matrix *cm = covariance_calculate_unnormalized (cov);
   size_t i;
   size_t k;
-  bool *model_dropped = xcalloc (covariance_dim (cov), sizeof (*model_dropped));
-  bool *submodel_dropped = xcalloc (covariance_dim (cov), sizeof (*submodel_dropped));
+  bool *model_dropped = XCALLOC (covariance_dim (cov), bool);
+  bool *submodel_dropped = XCALLOC (covariance_dim (cov), bool);
   const struct categoricals *cats = covariance_get_categoricals (cov);
 
   for (k = 0; k < cmd->n_interactions; k++)
@@ -524,8 +518,8 @@ ssq_type3 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd)
   const gsl_matrix *cm = covariance_calculate_unnormalized (cov);
   size_t i;
   size_t k;
-  bool *model_dropped = xcalloc (covariance_dim (cov), sizeof (*model_dropped));
-  bool *submodel_dropped = xcalloc (covariance_dim (cov), sizeof (*submodel_dropped));
+  bool *model_dropped = XCALLOC (covariance_dim (cov), bool);
+  bool *submodel_dropped = XCALLOC (covariance_dim (cov), bool);
   const struct categoricals *cats = covariance_get_categoricals (cov);
 
   double ss0;
@@ -860,8 +854,8 @@ parse_nested_variable (struct lexer *lexer, struct glm_spec *glm)
        return false;
     }
 
-  lex_error (lexer, "Nested variables are not yet implemented"); return false;
-  return true;
+  lex_error (lexer, "Nested variables are not yet implemented");
+  return false;
 }
 
 /* A design term is an interaction OR a nested variable */
@@ -872,7 +866,7 @@ parse_design_term (struct lexer *lexer, struct glm_spec *glm)
   if (parse_design_interaction (lexer, glm->dict, &iact))
     {
       /* Interaction parsing successful.  Add to list of interactions */
-      glm->interactions = xrealloc (glm->interactions, sizeof *glm->interactions * ++glm->n_interactions);
+      glm->interactions = xrealloc (glm->interactions, sizeof (*glm->interactions) * ++glm->n_interactions);
       glm->interactions[glm->n_interactions - 1] = iact;
       return true;
     }
@@ -902,4 +896,3 @@ parse_design_spec (struct lexer *lexer, struct glm_spec *glm)
 
   return parse_design_spec (lexer, glm);
 }
-