Changeset 4768
- Timestamp:
- 09/05/07 14:30:39 (6 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0/lib
- Files:
-
- 2 modified
-
conf-parse.y (modified) (6 diffs)
-
init.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/lib/conf-parse.y
r4756 r4768 38 38 static void sensors_yyerror(const char *err); 39 39 static sensors_expr *malloc_expr(void); 40 /* free_expr is defined in init.c */ 41 void free_expr(sensors_expr *expr); 40 42 41 43 static sensors_chip *current_chip = NULL; … … 78 80 sizeof(sensors_chip_name)); 79 81 80 /* YYERROR can only be called in rules, not in other functions, so this must81 be a macro */82 #define check_current_chip()\83 do { if (! current_chip) {\84 sensors_yyerror("Label, Set or Compute statement before first chip statement");\85 YYERROR;\86 }\87 } while (0)88 89 82 %} 90 83 … … 153 146 label_statement: LABEL function_name string 154 147 { sensors_label new_el; 155 check_current_chip(); 148 if (!current_chip) { 149 sensors_yyerror("Label statement before first chip statement"); 150 free($2); 151 free($3); 152 YYERROR; 153 } 156 154 new_el.lineno = $1; 157 155 new_el.name = $2; … … 163 161 set_statement: SET function_name expression 164 162 { sensors_set new_el; 165 check_current_chip(); 163 if (!current_chip) { 164 sensors_yyerror("Set statement before first chip statement"); 165 free($2); 166 free($3); 167 YYERROR; 168 } 166 169 new_el.lineno = $1; 167 170 new_el.name = $2; … … 173 176 compute_statement: COMPUTE function_name expression ',' expression 174 177 { sensors_compute new_el; 175 check_current_chip(); 178 if (!current_chip) { 179 sensors_yyerror("Compute statement before first chip statement"); 180 free($2); 181 free_expr($3); 182 free_expr($5); 183 YYERROR; 184 } 176 185 new_el.lineno = $1; 177 186 new_el.name = $2; … … 184 193 ignore_statement: IGNORE function_name 185 194 { sensors_ignore new_el; 186 check_current_chip(); 195 if (!current_chip) { 196 sensors_yyerror("Ignore statement before first chip statement"); 197 free($2); 198 YYERROR; 199 } 187 200 new_el.lineno = $1; 188 201 new_el.name = $2; -
lm-sensors/branches/lm-sensors-3.0.0/lib/init.c
r4760 r4768 72 72 } 73 73 74 staticvoid free_expr(sensors_expr *expr)74 void free_expr(sensors_expr *expr) 75 75 { 76 76 if (expr->kind == sensors_kind_var)
