- Many cleanups to make -Wall happy. Next up is pedantic...

This commit is contained in:
ccremers 2007-01-06 14:45:29 +00:00
parent 92090142a0
commit 89c3a20acf
31 changed files with 1871 additions and 1927 deletions

View File

@ -42,6 +42,8 @@
#include "arachne.h" #include "arachne.h"
#include "hidelevel.h" #include "hidelevel.h"
#include "depend.h" #include "depend.h"
#include "xmlout.h"
#include "heuristic.h"
extern int *graph; extern int *graph;
extern int nodes; extern int nodes;
@ -70,7 +72,6 @@ static FILE *attack_stream;
*/ */
int iterate (); int iterate ();
void printSemiState ();
/* /*
* Program code * Program code
@ -81,7 +82,6 @@ void
arachneInit (const System mysys) arachneInit (const System mysys)
{ {
Roledef rd; Roledef rd;
Termlist tl, know0;
void add_event (int event, Term message) void add_event (int event, Term message)
{ {
@ -666,7 +666,6 @@ create_decryptor (const Term term, const Term key)
if (term != NULL && isTermEncrypt (term)) if (term != NULL && isTermEncrypt (term))
{ {
Roledef rd; Roledef rd;
Term tempkey;
int run; int run;
#ifdef DEBUG #ifdef DEBUG
@ -692,15 +691,13 @@ create_decryptor (const Term term, const Term key)
return run; return run;
} }
else
{ globalError++;
globalError++; eprintf ("Term for which a decryptor instance is requested: ");
eprintf ("Term for which a decryptor instance is requested: "); termPrint (term);
termPrint (term); eprintf ("\n");
eprintf ("\n"); error ("Trying to build a decryptor instance for a non-encrypted term.");
error return -1;
("Trying to build a decryptor instance for a non-encrypted term.");
}
} }
//! Get the priority level of a key that is needed for a term (typical pk/sk distinction) //! Get the priority level of a key that is needed for a term (typical pk/sk distinction)
@ -1085,7 +1082,6 @@ printSemiState ()
{ {
int run; int run;
int open; int open;
List bl;
int binding_state_print (void *dt) int binding_state_print (void *dt)
{ {
@ -2237,7 +2233,7 @@ iterate_buffer_attacks (void)
} }
//! Arachne single claim test //! Arachne single claim test
int void
arachneClaimTest (Claimlist cl) arachneClaimTest (Claimlist cl)
{ {
// others we simply test... // others we simply test...
@ -2377,10 +2373,7 @@ arachneClaim (Claimlist cl)
} }
return true; return true;
} }
else return false;
{
return false;
}
} }
@ -2389,6 +2382,8 @@ arachneClaim (Claimlist cl)
* For this test, we manually set up some stuff. * For this test, we manually set up some stuff.
* *
* But later, this will just iterate over all claims. * But later, this will just iterate over all claims.
*
* @TODO what does it return? And is that -1 valid, if nothing is tested?
*/ */
int int
arachne () arachne ()
@ -2433,7 +2428,7 @@ arachne ()
if (switches.runs == 0) if (switches.runs == 0)
{ {
// No real checking. // No real checking.
return; return -1;
} }
if (sys->maxruns > 0) if (sys->maxruns > 0)

View File

@ -12,5 +12,9 @@ int isTriviallyKnownAtArachne (const System sys, const Term t, const int run,
const int index); const int index);
int isTriviallyKnownAfterArachne (const System sys, const Term t, int isTriviallyKnownAfterArachne (const System sys, const Term t,
const int run, const int index); const int run, const int index);
void arachneOutputAttack ();
void printSemiState ();
int countIntruderActions ();
void role_name_print (const int run);
#endif #endif

View File

@ -14,6 +14,7 @@
#include "arachne.h" #include "arachne.h"
#include "switches.h" #include "switches.h"
#include "depend.h" #include "depend.h"
#include "error.h"
#ifndef OSXHOST #ifndef OSXHOST
#include <malloc.h> #include <malloc.h>
#endif #endif
@ -178,6 +179,8 @@ goal_unbind (const Binding b)
//! Bind a goal as a dummy (block) //! Bind a goal as a dummy (block)
/** /**
* Especially made for tuple expansion * Especially made for tuple expansion
*
* @TODO Weird that this returns a value (always true, otherwise error)
*/ */
int int
binding_block (Binding b) binding_block (Binding b)
@ -187,13 +190,14 @@ binding_block (Binding b)
b->blocked = true; b->blocked = true;
return true; return true;
} }
else error ("Trying to block a goal again.");
{ return false;
error ("Trying to block a goal again.");
}
} }
//! Unblock a binding //! Unblock a binding
/*
* @TODO Weird that this returns a value (always true, otherwise error)
*/
int int
binding_unblock (Binding b) binding_unblock (Binding b)
{ {
@ -202,10 +206,8 @@ binding_unblock (Binding b)
b->blocked = false; b->blocked = false;
return true; return true;
} }
else error ("Trying to unblock a non-blocked goal.");
{ return false;
error ("Trying to unblock a non-blocked goal.");
}
} }

View File

@ -18,6 +18,8 @@
#include "specialterm.h" #include "specialterm.h"
#include "switches.h" #include "switches.h"
#include "color.h" #include "color.h"
#include "cost.h"
#include "timer.h"
//! When none of the runs match //! When none of the runs match
#define MATCH_NONE 0 #define MATCH_NONE 0
@ -39,6 +41,10 @@ extern int attack_leastcost;
// Debugging the NI-SYNCH checks // Debugging the NI-SYNCH checks
//#define OKIDEBUG //#define OKIDEBUG
// Forward declaration
int oki_nisynch (const System sys, const int trace_index,
const Termmap role_to_run, const Termmap label_to_index);
/* /*
* Validity checks for claims * Validity checks for claims
* *
@ -367,6 +373,7 @@ oki_nisynch (const System sys, const int trace_index,
* Exception: no claim, no send, no read, what is it? * Exception: no claim, no send, no read, what is it?
*/ */
error ("Unrecognized event type in claim scanner at %i.", trace_index); error ("Unrecognized event type in claim scanner at %i.", trace_index);
return 0;
} }
/* /*

View File

@ -6,4 +6,7 @@ extern char *COLOR_Red;
extern char *COLOR_Green; extern char *COLOR_Green;
extern char *COLOR_Bold; extern char *COLOR_Bold;
void colorInit (void);
void colorDone (void);
#endif #endif

View File

@ -16,6 +16,7 @@
#include "hidelevel.h" #include "hidelevel.h"
#include "debug.h" #include "debug.h"
#include "intruderknowledge.h" #include "intruderknowledge.h"
#include "error.h"
/* /*
Simple sys pointer as a global. Yields cleaner code although it's against programming standards. Simple sys pointer as a global. Yields cleaner code although it's against programming standards.
@ -438,7 +439,6 @@ claimCreate (const System sys, const Protocol protocol, const Role role,
const Term claim, Term label, const Term msg) const Term claim, Term label, const Term msg)
{ {
Claimlist cl; Claimlist cl;
Term labeltuple;
/* generate full unique label */ /* generate full unique label */
/* is the label empty or used? */ /* is the label empty or used? */
@ -556,6 +556,7 @@ claimCreate (const System sys, const Protocol protocol, const Role role,
claimvars = claimvars->next; claimvars = claimvars->next;
} }
} }
return cl;
} }
//! Parse a communication event tc of type event, and add a role definition event for it. //! Parse a communication event tc of type event, and add a role definition event for it.
@ -1390,7 +1391,6 @@ compute_prec_sets (const System sys)
int size; // temp constant: rolecount * roleeventmax int size; // temp constant: rolecount * roleeventmax
int rowsize; int rowsize;
int r1, r2, ev1, ev2; // some counters int r1, r2, ev1, ev2; // some counters
int i, j;
Claimlist cl; Claimlist cl;
// Assist: compute index from role, lev // Assist: compute index from role, lev
@ -1583,7 +1583,6 @@ compute_prec_sets (const System sys)
cl = sys->claimlist; cl = sys->claimlist;
while (cl != NULL) while (cl != NULL)
{ {
Term t;
Roledef rd; Roledef rd;
Term label; Term label;
int claim_index; int claim_index;

View File

@ -8,6 +8,8 @@
*/ */
#include "switches.h" #include "switches.h"
#include "system.h" #include "system.h"
#include "binding.h"
#include "error.h"
#include <limits.h> #include <limits.h>
//************************************************************************ //************************************************************************
@ -68,4 +70,5 @@ attackCost (const System sys)
return cost; return cost;
} }
error ("Unknown pruning method (cost function not found)"); error ("Unknown pruning method (cost function not found)");
return 0;
} }

View File

@ -7,6 +7,7 @@
#include "depend.h" #include "depend.h"
#include "type.h" #include "type.h"
#include "debug.h" #include "debug.h"
#include "error.h"
extern Protocol INTRUDER; // Pointers, to be set by the Init of arachne.c extern Protocol INTRUDER; // Pointers, to be set by the Init of arachne.c
extern Role I_M; // Same here. extern Role I_M; // Same here.
@ -1645,7 +1646,6 @@ void
dotSemiState (const System mysys) dotSemiState (const System mysys)
{ {
static int attack_number = 0; static int attack_number = 0;
int run;
Protocol p; Protocol p;
int *ranks; int *ranks;
int maxrank; int maxrank;

View File

@ -7,12 +7,15 @@
*/ */
#include <float.h> #include <float.h>
#include <stdlib.h>
#include "binding.h" #include "binding.h"
#include "system.h" #include "system.h"
#include "specialterm.h" #include "specialterm.h"
#include "switches.h" #include "switches.h"
#include "hidelevel.h" #include "hidelevel.h"
#include "arachne.h"
#include "error.h"
//! Check whether a binding (goal) is selectable //! Check whether a binding (goal) is selectable
int int
@ -211,8 +214,6 @@ float
weighHidelevel (const System sys, const Term t, const float massknow, weighHidelevel (const System sys, const Term t, const float massknow,
const float massprot) const float massprot)
{ {
unsigned int hl;
switch (hidelevelFlag (sys, t)) switch (hidelevelFlag (sys, t))
{ {
case HLFLAG_NONE: case HLFLAG_NONE:
@ -253,6 +254,7 @@ term_constcount (const System sys, Term t)
n++; n++;
} }
} }
return 1;
} }
n = 0; n = 0;

View File

@ -125,7 +125,7 @@ initialIntruderKnowledge (const System sys)
* Hack. Enumerating is not always good (or even desirable). * Hack. Enumerating is not always good (or even desirable).
* If some I knows sk(I), sk should not be in the intruder knowledge. * If some I knows sk(I), sk should not be in the intruder knowledge.
* But for hash(I), we typically would have h; but if it is never used differently, it would suffice. * But for hash(I), we typically would have h; but if it is never used differently, it would suffice.
* To sommarize, the operational semantics definition is perfectly fine, but maybe a bit strict sometimes. * To summarize, the operational semantics definition is perfectly fine, but maybe a bit strict sometimes.
* *
* The hack is that if function application: * The hack is that if function application:
*/ */

View File

@ -10,6 +10,7 @@
#include "knowledge.h" #include "knowledge.h"
#include "system.h" #include "system.h"
#include "debug.h" #include "debug.h"
#include "error.h"
/* /*
* Knowledge stuff * Knowledge stuff

View File

@ -56,7 +56,6 @@ Termlist knowledgeNew (const Knowledge oldk, const Knowledge newk);
//! Harnass macro for recursive procedures. //! Harnass macro for recursive procedures.
#define mindwipe(k,recurse) \ #define mindwipe(k,recurse) \
Termlist tl; \ Termlist tl; \
Term oldsubst; \
int flag; \ int flag; \
if (k != NULL && k->vars != NULL) { \ if (k != NULL && k->vars != NULL) { \
tl = k->vars; \ tl = k->vars; \

View File

@ -53,6 +53,8 @@
#include "color.h" #include "color.h"
#include "error.h" #include "error.h"
#include "claim.h" #include "claim.h"
#include "arachne.h"
#include "xmlout.h"
//! The global system state pointer //! The global system state pointer
System sys; System sys;
@ -75,7 +77,6 @@ int modelCheck (const System sys);
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
int nerrors;
int exitcode = EXIT_NOATTACK; int exitcode = EXIT_NOATTACK;
/* initialize symbols */ /* initialize symbols */
@ -217,7 +218,6 @@ main (int argc, char **argv)
/* memory clean up? */ /* memory clean up? */
strings_cleanup (); strings_cleanup ();
exit:
return exitcode; return exitcode;
} }

File diff suppressed because it is too large Load Diff

View File

@ -38,28 +38,27 @@
# define YYTOKENTYPE # define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers /* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */ know about them. */
enum yytokentype enum yytokentype {
{ ID = 258,
ID = 258, PROTOCOL = 259,
PROTOCOL = 259, ROLE = 260,
ROLE = 260, READT = 261,
READT = 261, SENDT = 262,
SENDT = 262, CLAIMT = 263,
CLAIMT = 263, VAR = 264,
VAR = 264, CONST = 265,
CONST = 265, RUN = 266,
RUN = 266, SECRET = 267,
SECRET = 267, COMPROMISED = 268,
COMPROMISED = 268, INVERSEKEYS = 269,
INVERSEKEYS = 269, UNTRUSTED = 270,
UNTRUSTED = 270, USERTYPE = 271,
USERTYPE = 271, SINGULAR = 272,
SINGULAR = 272, FUNCTION = 273,
FUNCTION = 273, HASHFUNCTION = 274,
HASHFUNCTION = 274, KNOWS = 275,
KNOWS = 275, TRUSTED = 276
TRUSTED = 276 };
};
#endif #endif
/* Tokens. */ /* Tokens. */
#define ID 258 #define ID 258
@ -87,19 +86,20 @@ enum yytokentype
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 13 "parser.y" #line 14 "parser.y"
{ {
char *str; char* str;
struct tacnode *tac; struct tacnode* tac;
Symbol symb; Symbol symb;
int value; int value;
} }
/* Line 1529 of yacc.c. */ /* Line 1529 of yacc.c. */
#line 98 "parser.h" #line 98 "parser.h"
YYSTYPE; YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;

View File

@ -2,6 +2,7 @@
#include "pheading.h" #include "pheading.h"
/* #include "lex.yy.c" */ /* #include "lex.yy.c" */
#include "tac.h" #include "tac.h"
#include "error.h"
struct tacnode* spdltac; struct tacnode* spdltac;
@ -319,6 +320,7 @@ int yyerror(char *s)
extern char *yytext; //!< defined and maintained in lex.c extern char *yytext; //!< defined and maintained in lex.c
error ("%s at symbol '%s' on line %i.\n", s, yytext, yylineno); error ("%s at symbol '%s' on line %i.\n", s, yytext, yylineno);
return 0;
} }

View File

@ -11,6 +11,10 @@
#include "termlist.h" #include "termlist.h"
#include "list.h" #include "list.h"
#include "switches.h" #include "switches.h"
#include "timer.h"
#include "arachne.h"
#include "system.h"
#include "cost.h"
extern int attack_length; extern int attack_length;
extern int attack_leastcost; extern int attack_leastcost;
@ -27,9 +31,6 @@ extern int max_encryption_level;
int int
prune_bounds (const System sys) prune_bounds (const System sys)
{ {
Termlist tl;
List bl;
/* prune for time */ /* prune for time */
if (passed_time_limit ()) if (passed_time_limit ())
{ {

View File

@ -13,6 +13,10 @@
#include "binding.h" #include "binding.h"
#include "specialterm.h" #include "specialterm.h"
#include "hidelevel.h" #include "hidelevel.h"
#include "depend.h"
#include "arachne.h"
#include "error.h"
#include "type.h"
extern Protocol INTRUDER; extern Protocol INTRUDER;
extern int proofDepth; extern int proofDepth;
@ -106,9 +110,8 @@ correctLocalOrder (const System sys)
globalError--; globalError--;
error ("Abort"); error ("Abort");
} }
return true;
} }
return true;
} }
return iterateLocalToOther (sys, r1, checkTerm); return iterateLocalToOther (sys, r1, checkTerm);
@ -162,7 +165,6 @@ initiatorAgentsType (const System sys)
int int
prune_theorems (const System sys) prune_theorems (const System sys)
{ {
Termlist tl;
List bl; List bl;
int run; int run;

View File

@ -11,6 +11,7 @@
#include "knowledge.h" #include "knowledge.h"
#include "system.h" #include "system.h"
#include "debug.h" #include "debug.h"
#include "error.h"
#include "role.h" #include "role.h"
extern int protocolCount; // from system.c extern int protocolCount; // from system.c

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@
#include "term.h" #include "term.h"
#include "termlist.h" #include "termlist.h"
#include "compiler.h" #include "compiler.h"
#include "error.h"
/* /*
* Some macros * Some macros

View File

@ -3,6 +3,7 @@
#include "term.h" #include "term.h"
#include "termlist.h" #include "termlist.h"
#include "system.h"
/* /*
* Some declarations in spercialterm.c * Some declarations in spercialterm.c
@ -25,6 +26,7 @@ extern Term CLAIM_Reachable;
extern Termlist CLAIMS_dep_prec; extern Termlist CLAIMS_dep_prec;
void specialTermInit (const System sys);
int isTicketTerm (Term t); int isTicketTerm (Term t);
int hasTicketSubterm (Term t); int hasTicketSubterm (Term t);

View File

@ -1,4 +1,5 @@
#include "states.h" #include "states.h"
#include "symbol.h"
/* States counter operations /* States counter operations
* *

View File

@ -282,7 +282,6 @@ switcher (const int process, int index, int commandline)
char **argv; char **argv;
char *arg_pointer; char *arg_pointer;
int arg_index;
//! Check whether there are still n options left //! Check whether there are still n options left
int enough_arguments_left (const int n, char shortopt, char *longopt) int enough_arguments_left (const int n, char shortopt, char *longopt)

View File

@ -266,6 +266,7 @@ symbolNextFree (Symbol prefixsymbol)
} }
error ("We ran out of numbers (%i) when trying to generate a fresh symbol.", error ("We ran out of numbers (%i) when trying to generate a fresh symbol.",
n); n);
return NULL;
} }
//! Fix all the unset keylevels //! Fix all the unset keylevels

View File

@ -10,6 +10,7 @@
#include "knowledge.h" #include "knowledge.h"
#include "system.h" #include "system.h"
#include "debug.h" #include "debug.h"
#include "error.h"
#include "role.h" #include "role.h"
#include "mgu.h" #include "mgu.h"
#include "switches.h" #include "switches.h"
@ -148,7 +149,6 @@ systemRuns (const System sys)
void void
systemDone (const System sys) systemDone (const System sys)
{ {
int run;
int s; int s;
/* clear globals, which were defined in systemStart */ /* clear globals, which were defined in systemStart */

View File

@ -212,6 +212,7 @@ int selfResponder (const System sys, const int run);
int selfResponders (const System sys); int selfResponders (const System sys);
int selfInitiator (const System sys, const int run); int selfInitiator (const System sys, const int run);
int selfInitiators (const System sys); int selfInitiators (const System sys);
int enoughAttacks (const System sys);
//! Equality for run structure naming //! Equality for run structure naming

View File

@ -3,6 +3,7 @@
#include "tac.h" #include "tac.h"
#include "memory.h" #include "memory.h"
#include "switches.h" #include "switches.h"
#include "error.h"
extern int yylineno; extern int yylineno;
@ -183,6 +184,8 @@ tacTuple (Tac taclist)
error ("Unknown tupling mode (--tupling=%i)", switches.tupling); error ("Unknown tupling mode (--tupling=%i)", switches.tupling);
} }
} }
// @TODO this should be considered an error
return NULL;
} }
/* /*

View File

@ -16,6 +16,7 @@
#include <string.h> #include <string.h>
#include "term.h" #include "term.h"
#include "debug.h" #include "debug.h"
#include "error.h"
#include "ctype.h" #include "ctype.h"
#include "specialterm.h" #include "specialterm.h"
@ -866,9 +867,6 @@ termDistance (Term t1, Term t2)
int int
termOrder (Term t1, Term t2) termOrder (Term t1, Term t2)
{ {
char *name1;
char *name2;
t1 = deVar (t1); t1 = deVar (t1);
t2 = deVar (t2); t2 = deVar (t2);
if (isTermEqual (t1, t2)) if (isTermEqual (t1, t2))
@ -938,6 +936,8 @@ termOrder (Term t1, Term t2)
else else
return compR; return compR;
} }
// @TODO Should be considered an error
return 0;
} }
//! Generic term iteration //! Generic term iteration
@ -1177,7 +1177,6 @@ term_constrain_level (const Term term)
{ {
int vars; int vars;
int structure; int structure;
int flag;
void tcl_iterate (Term t) void tcl_iterate (Term t)
{ {

View File

@ -3,6 +3,7 @@
#include "termlist.h" #include "termlist.h"
#include "specialterm.h" #include "specialterm.h"
#include "debug.h" #include "debug.h"
#include "error.h"
/* /*
* Shared stuff * Shared stuff
@ -912,6 +913,8 @@ termlist_to_tuple (Termlist tl)
return termDuplicate (tl->term); return termDuplicate (tl->term);
} }
} }
// @TODO Should be considered an error
return NULL;
} }
//! Split a tuple term into termlist components. //! Split a tuple term into termlist components.

View File

@ -21,6 +21,7 @@
#include "specialterm.h" #include "specialterm.h"
#include "claim.h" #include "claim.h"
#include "dotout.h" #include "dotout.h"
#include "type.h"
#include "xmlout.h" #include "xmlout.h"
@ -614,8 +615,6 @@ xmlOutEvent (const System sys, Roledef rd, const int run, const int index)
// Display any incoming bindings // Display any incoming bindings
{ {
int incomingArrows;
int xmlBindingState (void *dt) int xmlBindingState (void *dt)
{ {
Binding b; Binding b;