replacement in vertex.h at line 20
+ typedef struct {
+ } Position;
replacement in vertex.h at line 27
replacement in vertex.h at line 30
edit in init.c at line 4
replacement in hunk.h at line 4
− struct local {
− char *path;
− };
+ typedef struct {
+ str path;
+ } Local;
replacement in hunk.h at line 8
replacement in hunk.h at line 22
replacement in hunk.h at line 24
[6.965]→[6.965:1000](∅→∅) − struct file_move {
− char *path;
− };
+ typedef struct {
+ str path;
+ } Filemove;
replacement in hunk.h at line 28
[6.1001]→[6.1001:1015](∅→∅) replacement in hunk.h at line 30
[6.1031]→[6.1031:1034](∅→∅) replacement in hunk.h at line 32
[6.1035]→[6.1035:1056](∅→∅) replacement in hunk.h at line 35
[6.1095]→[6.1095:1119](∅→∅) − struct local local;
− };
+ Local local;
+ } Replacement;
replacement in hunk.h at line 38
[6.1120]→[6.1120:1169](∅→∅) − struct basehunk {
− enum basehunk_type hunk_type;
+ typedef struct {
+ basehunktype hunktype;
replacement in hunk.h at line 41
[6.1178]→[6.1178:1263](∅→∅) − struct file_move file_move;
− struct edit edit;
− struct replacement replacement;
−
+ Filemove filemove;
+ Edit edit;
+ Replacement replacement;
replacement in hunk.h at line 45
[6.1272]→[6.1272:1275](∅→∅) replacement in hunk.h at line 47
[6.1276]→[6.1276:1332](∅→∅) − const char *hunk_basehunk_type_str(enum basehunk_type);
+ const char *hunk_basehunk_type_str(basehunktype);
edit in hunk.c at line 3
replacement in hunk.c at line 8
[6.1445]→[6.1445:1498](∅→∅) − hunk_basehunk_type_str(enum basehunk_type hunk_type)
+ hunk_basehunk_type_str(basehunktype hunk_type)
replacement in hash.h at line 9
replacement in hash.h at line 12
replacement in hash.h at line 14
replacement in hash.h at line 16
− struct hash *entries;
− };
+ Hash *entries;
+ } Hashlist;
replacement in hash.h at line 19
− void hash_print(struct hash *);
+ void hashprint(Hash *);
edit in hash.c at line 6
replacement in hash.c at line 11
− hash_print(struct hash *hash)
replacement in hash.c at line 21
− base32_encode_hash(b32hash, hash->bytes);
+ base32_hashencode(b32hash, hash->bytes);
file addition: common.h (----------)
+ #ifndef ANI_COMMON_H
+ #define ANI_COMMON_H
+
+ typedef char * str;
+
+ /* Banned functions */
+
+ /*
+ * This header lists functions that have been banned from our code base,
+ * because they're too easy to misuse (and even if used correctly,
+ * complicate audits). Including this header turns them into compile-time
+ * errors.
+ */
+
+ #define BANNED(func) sorry_##func##_is_a_banned_function
+
+ #undef strcpy
+ #define strcpy(x, y) BANNED(strcpy)
+ #undef strcat
+ #define strcat(x, y) BANNED(strcat)
+ #undef strncpy
+ #define strncpy(x, y, n) BANNED(strncpy)
+ #undef strncat
+ #define strncat(x, y, n) BANNED(strncat)
+
+ #undef sprintf
+ #undef vsprintf
+ #define sprintf(...) BANNED(sprintf)
+ #define vsprintf(...) BANNED(vsprintf)
+
+ #undef gmtime
+ #define gmtime(t) BANNED(gmtime)
+ #undef localtime
+ #define localtime(t) BANNED(localtime)
+ #undef ctime
+ #define ctime(t) BANNED(ctime)
+ #undef ctime_r
+ #define ctime_r(t, buf) BANNED(ctime_r)
+ #undef asctime
+ #define asctime(t) BANNED(asctime)
+ #undef asctime_r
+ #define asctime_r(t, buf) BANNED(asctime_r)
+
+ #endif
replacement in change.h at line 15
replacement in change.h at line 23
[7.409]→[7.634:637](∅→∅),
[7.634]→[7.634:637](∅→∅) replacement in change.h at line 35
− /**
− * A list of key-value collections (BTreeMap)
− */
− struct authors {
− size_t len;
− struct author *map;
− };
+ typedef struct {
+ str key;
+ str value;
+ } Authorentry;
replacement in change.h at line 41
replacement in change.h at line 43
− struct author_entry *entries;
− };
+ Authorentry *entries;
+ } Author;
replacement in change.h at line 46
− struct author_entry {
− char *key;
− char *value;
− };
+ /**
+ * A list of key-value collections (BTreeMap)
+ */
+ typedef struct {
+ size_t len;
+ Author *map;
+ } Authors;
replacement in change.h at line 54
[7.285]→[7.0:173](∅→∅),
[7.810]→[7.0:173](∅→∅),
[7.173]→[7.410:477](∅→∅),
[7.353]→[7.209:212](∅→∅),
[7.477]→[7.209:212](∅→∅),
[7.573]→[7.209:212](∅→∅),
[7.209]→[7.209:212](∅→∅) − struct change_header {
− char *message; /* the "commit" message */
− char *description; /* the other undescribed part of a change */
− char *timestamp; /* yes, as a string */
− struct authors authors; /* a list of "key"="value" collections */
− };
+ typedef struct {
+ str message; /* the "commit" message */
+ str description; /* the other undescribed part of a change */
+ str timestamp; /* yes, as a string */
+ Authors authors; /* a list of "key"="value" collections */
+ } Changeheader;
replacement in change.h at line 68
replacement in change.h at line 70
[7.542]→[7.538:568](∅→∅),
[7.538]→[7.538:568](∅→∅),
[7.568]→[7.543:659](∅→∅),
[7.659]→[7.661:664](∅→∅),
[7.817]→[7.661:664](∅→∅),
[7.661]→[7.661:664](∅→∅) − struct change_header header;
− struct hash_list dependencies; /* array of hashes */
− struct hash_list extra_known; /* another array of hashes */
− };
+ Changeheader header;
+ Hashlist dependencies; /* array of hashes */
+ Hashlist extraknown; /* another array of hashes */
+ } Hashed;
replacement in change.h at line 81
[7.959]→[7.959:1005](∅→∅) − int decode_offsets(int fd, struct offsets *);
+ int decode_offsets(int fd, Offsets *);
edit in change.c at line 10
edit in change.c at line 18
[7.618]→[6.2151:2152](∅→∅) edit in change.c at line 38
[7.3]→[7.3:15](∅→∅),
[7.15]→[7.0:21](∅→∅),
[7.21]→[7.36:78](∅→∅),
[7.36]→[7.36:78](∅→∅),
[7.78]→[7.0:3](∅→∅),
[7.238]→[7.0:3](∅→∅) − static void
− cmd_change_usage()
− {
− printf("ani change [-h] [-v] <hash>\n");
− }
−
replacement in change.c at line 49
− change_decode_offsets(int fd, struct offsets *off)
+ change_decode_offsets(int fd, Offsets *off)
replacement in change.c at line 53
− struct bincode_state binstat;
replacement in change.c at line 156
− change_decode_hashlist(struct bincode_state *binstat, struct hash_list *target)
+ change_decode_hashlist(Bincode *binstat, Hashlist *target)
replacement in change.c at line 163
− target->entries = xmalloc(sizeof(struct hash) * len);
+ target->entries = xmalloc(sizeof(Hash) * len);
replacement in change.c at line 184
[6.2257]→[6.2257:2311](∅→∅) − change_decode_position(struct bincode_state *binstat)
+ change_decode_position(Bincode *binstat)
replacement in change.c at line 186
[6.2313]→[6.2313:2380](∅→∅) − uint64_t change_position; /* FIXME this should be its own type */
+ uint64_t changepos; /* FIXME this should be its own type */
replacement in change.c at line 189
[6.2412]→[6.2412:2432](∅→∅) replacement in change.c at line 202
[6.2670]→[6.2670:2691](∅→∅) replacement in change.c at line 204
[6.2694]→[6.2694:2789](∅→∅) − change_position = bincode_getu64(binstat);
− printf("ChangePosition(%lu)\n", change_position);
+ changepos = bincode_getu64(binstat);
+ printf("ChangePosition(%lu)\n", changepos);
replacement in change.c at line 209
[6.2797]→[6.2797:2850](∅→∅) − change_decode_newedge(struct bincode_state *binstat)
+ change_decode_newedge(Bincode *binstat)
replacement in change.c at line 226
[6.3269]→[6.3269:3319](∅→∅) − change_decode_atom(struct bincode_state *binstat)
+ change_decode_atom(Bincode *binstat)
replacement in change.c at line 255
[6.3802]→[6.3802:3853](∅→∅) − change_decode_hunks(struct bincode_state *binstat)
+ change_decode_hunks(Bincode *binstat)
replacement in change.c at line 262
[6.3940]→[6.3940:3998](∅→∅) − enum basehunk_type hunk_type = bincode_getu32(binstat);
+ basehunktype hunk_type = bincode_getu32(binstat);
replacement in change.c at line 293
− uint8_t *expected_hash, struct hashed *hashed
+ uint8_t *expected_hash, Hashed *hashed
replacement in change.c at line 302
− struct bincode_state binstat;
replacement in change.c at line 358
− hashed->header.authors.map = xmalloc(sizeof(struct author) * len);
+ hashed->header.authors.map = xmalloc(sizeof(Author) * len);
replacement in change.c at line 364
[4.522]→[7.1290:1331](∅→∅),
[7.1290]→[7.1290:1331](∅→∅) − xmalloc(sizeof(struct author) * len);
+ xmalloc(sizeof(Author) * len);
replacement in change.c at line 380
[7.1575]→[4.790:847](∅→∅) − change_decode_hashlist(&binstat, &hashed->extra_known);
+ change_decode_hashlist(&binstat, &hashed->extraknown);
replacement in change.c at line 410
[7.1722]→[7.1722:1772](∅→∅) − change_read_contents(int fd, struct offsets *off)
+ change_read_contents(int fd, Offsets *off)
replacement in change.c at line 426
[7.121]→[7.2233:2254](∅→∅),
[7.2233]→[7.2233:2254](∅→∅) replacement in change.c at line 432
[7.2126]→[4.895:918](∅→∅) replacement in change.c at line 447
[7.2474]→[7.1430:1472](∅→∅) − base32_decode_hash(contents_hash, hash);
+ base32_hashdecode(contents_hash, hash);
replacement in change.c at line 493
[4.2072]→[4.2072:2119](∅→∅) − hash_print(&hashed.dependencies.entries[i]);
+ hashprint(&hashed.dependencies.entries[i]);
replacement in change.c at line 495
[4.2122]→[4.2122:2170](∅→∅) − for (i = 0; i < hashed.extra_known.len; i++) {
+ for (i = 0; i < hashed.extraknown.len; i++) {
replacement in change.c at line 497
[4.2185]→[4.2185:2231](∅→∅) − hash_print(&hashed.extra_known.entries[i]);
+ hashprint(&hashed.extraknown.entries[i]);
edit in change.c at line 517
+ }
+
+ static void
+ cmd_change_usage()
+ {
+ printf("ani change [-h] [-v] <hash>\n");
replacement in bincode.h at line 20
[7.1998]→[7.786:809](∅→∅) replacement in bincode.h at line 23
replacement in bincode.h at line 31
[7.2156]→[7.871:1065](∅→∅) − uint8_t bincode_getu8(struct bincode_state *);
− uint16_t bincode_getu16(struct bincode_state *);
− uint32_t bincode_getu32(struct bincode_state *);
− uint64_t bincode_getu64(struct bincode_state *);
+ uint8_t bincode_getu8(Bincode *);
+ uint16_t bincode_getu16(Bincode *);
+ uint32_t bincode_getu32(Bincode *);
+ uint64_t bincode_getu64(Bincode *);
replacement in bincode.h at line 44
[7.2502]→[7.1066:1120](∅→∅),
[7.1120]→[6.4819:4885](∅→∅) − char *bincode_getstr(struct bincode_state *, size_t);
− void bincode_getbytes(struct bincode_state *, uint8_t *, size_t);
+ char *bincode_getstr(Bincode *, size_t);
+ void bincode_getbytes(Bincode *, uint8_t *, size_t);
edit in bincode.c at line 5
replacement in bincode.c at line 11
[7.1130]→[7.1130:1169](∅→∅) − bincode_getu8(struct bincode_state *s)
+ bincode_getu8(Bincode *s)
replacement in bincode.c at line 23
[7.2866]→[7.1252:1292](∅→∅) − bincode_getu16(struct bincode_state *s)
+ bincode_getu16(Bincode *s)
replacement in bincode.c at line 37
[7.2953]→[7.1339:1379](∅→∅) − bincode_getu32(struct bincode_state *s)
+ bincode_getu32(Bincode *s)
replacement in bincode.c at line 52
[7.3092]→[7.1426:1466](∅→∅) − bincode_getu64(struct bincode_state *s)
+ bincode_getu64(Bincode *s)
replacement in bincode.c at line 69
[7.3329]→[7.1513:1565](∅→∅) − bincode_getstr(struct bincode_state *s, size_t len)
+ bincode_getstr(Bincode *s, size_t len)
replacement in bincode.c at line 85
[6.4891]→[6.4891:4960](∅→∅) − bincode_getbytes(struct bincode_state *s, uint8_t *dest, size_t len)
+ bincode_getbytes(Bincode *s, uint8_t *dest, size_t len)
replacement in base32.h at line 10
[7.1831]→[7.1831:1886](∅→∅) − void base32_decode_hash(uint8_t *dst, char const *in);
+ void base32_hashdecode(uint8_t *dst, char const *in);
replacement in base32.h at line 12
− void base32_encode_hash(char *dst, uint8_t const *in);
+ void base32_hashencode(char *dst, uint8_t const *in);
edit in base32.c at line 2
replacement in base32.c at line 49
[7.3080]→[7.3080:3129](∅→∅) − base32_decode_hash(uint8_t *dst, char const *in)
+ base32_hashdecode(uint8_t *dst, char const *in)
replacement in base32.c at line 88
[2.983]→[2.983:1034](∅→∅) − base32_encode_hash(char *dst, uint8_t const *hash)
+ base32_hashencode(char *dst, uint8_t const *hash)
replacement in atom.h at line 10
[6.5201]→[6.5201:5218](∅→∅) replacement in atom.h at line 13
[6.5241]→[6.5241:5244](∅→∅) replacement in atom.h at line 15
[6.5245]→[6.5245:5342](∅→∅) − struct new_vertex {
− struct hash up_context; /* FIXME Option<Hash> */
− struct hash down_context;
+ typedef struct {
+ Hash upcontext; /* FIXME Option<Hash> */
+ Hash downcontext;
replacement in atom.h at line 22
[6.5530]→[6.5530:5533](∅→∅) + } Newvertex;
+
+ typedef struct {
+ } Edgemap;
replacement in atom.h at line 28
[6.5548]→[6.5548:5575](∅→∅) − enum atom_type atom_type;
replacement in atom.h at line 30
[6.5584]→[6.5584:5616](∅→∅) − struct new_vertex new_vertex;
+ Newvertex newvertex;
+ Edgemap edgemap;
edit in ani.c at line 4
replacement in ani.c at line 17
[7.3226]→[7.1173:1186](∅→∅),
[7.174]→[7.1173:1186](∅→∅) replacement in ani.c at line 20
[7.1237]→[7.1237:1240](∅→∅) replacement in ani.c at line 22
[7.1241]→[7.1241:1274](∅→∅) − static struct cmd commands[] = {
+ static Cmd commands[] = {
replacement in ani.c at line 37
[7.1354]→[7.1354:1374](∅→∅) replacement in ani.c at line 41
[7.1408]→[7.1408:1424](∅→∅) replacement in ani.c at line 54
[7.350]→[7.1606:1628](∅→∅),
[7.1606]→[7.1606:1628](∅→∅) edit in README.md at line 34
+
+ ### Header files
+
+ Simple rule: include files should never include include files (see
+ [pikestyle][pikestyle]). Instead they state (in comments or implicitly)
+ what files they need to have included first, the problem of deciding which
+ files to include is pushed to the user. (vendored header files are exempted
+ from this rule to make it easier to update a vendored dependency.)
replacement in README.md at line 43
+ In addition, system include files should be grouped first before any user
+ include files, and the first user include file _must_ be common.h. All .c
+ files in this project _must_ include common.h As an example, this is the
+ correct way to include files:
+
+ #include <stdlib.h>
+ #include <stdint.h>
+ #include <stdio.h>
replacement in README.md at line 52
− Simple rule: include files should never include include files. Instead they
− state (in comments or implicitly) what files they need to have included first,
− the problem of deciding which files to include is pushed to the user.
+ #include "common.h"
+ #include "atom.h"
+
+ Prefer to leave a blank line in between the system includes and user includes.
+
+ ### Type declarations
replacement in README.md at line 59
− [ the above is listed straight from pikestyle, see [pikestyle][pikestyle] ]
+ Structs are the only types that should be declared with a capital
+ letter. Simple types should be declared with lowercase letters.