{"thread":{"id":"31436","subject":"[PATCH 2/3] read-cache.c: Pass 'struct stat' parameters by reference","startedAt":"2012-09-04T18:52:14Z","lastAt":"2012-09-04T18:52:14Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"198333","messageId":"50464DDE.2070105@ramsay1.demon.co.uk","threadId":"31436","inReplyTo":null,"subject":"[PATCH 2/3] read-cache.c: Pass 'struct stat' parameters by reference","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-09-04T18:52:14Z","receivedAt":"2012-09-04T18:52:14Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nHi Thomas,\n\nPassing the 'struct stat' parameters by value, while not *wrong*, looks\nsomewhat odd to my eyes. As I said before, feel free to ignore this one.\n\nATB,\nRamsay Jones\n\n read-cache.c | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 211b971..36f0877 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1199,25 +1199,25 @@ int read_index(struct index_state *istate)\n \treturn read_index_from(istate, get_index_file());\n }\n \n-static int index_changed(struct stat st_old, struct stat st_new)\n+static int index_changed(struct stat *st_old, struct stat *st_new)\n {\n \tint changed = 0;\n \n-\tif (st_old.st_mtime != st_new.st_mtime ||\n+\tif (st_old->st_mtime != st_new->st_mtime ||\n #if !defined(__CYGWIN__)\n-\t    st_old.st_uid   != st_new.st_uid ||\n-\t    st_old.st_gid   != st_new.st_gid ||\n-\t    st_old.st_ino   != st_new.st_ino ||\n+\t    st_old->st_uid   != st_new->st_uid ||\n+\t    st_old->st_gid   != st_new->st_gid ||\n+\t    st_old->st_ino   != st_new->st_ino ||\n #endif\n-\t    st_old.st_size  != st_new.st_size)\n+\t    st_old->st_size  != st_new->st_size)\n \t\tchanged = 1;\n #ifdef USE_NSEC\n-\tif (ST_MTIME_NSEC(st_old) != ST_MTIME_NSEC(st_new))\n+\tif (ST_MTIME_NSEC(*st_old) != ST_MTIME_NSEC(*st_new))\n \t\tchanged = 1;\n #endif\n \n #ifdef USE_STDEV\n-\tif (st_old.st_dev != st_new.st_dev)\n+\tif (st_old->st_dev != st_new->st_dev)\n \t\tchanged = 1;\n #endif\n \n@@ -1273,12 +1273,12 @@ int read_index_from(struct index_state *istate, const char *path)\n \n \t\tmunmap(mmap, mmap_size);\n \n-\t\tif (!index_changed(st_old, st_new) && !err)\n+\t\tif (!index_changed(&st_old, &st_new) && !err)\n \t\t\treturn istate->cache_nr;\n \n \t\tusleep(10*1000);\n \t\ti++;\n-\t} while ((err || index_changed(st_old, st_new)) && i < 50);\n+\t} while ((err || index_changed(&st_old, &st_new)) && i < 50);\n \n \tmunmap(mmap, mmap_size);\n \tdie(\"index file corrupt\");\n-- \n1.7.12\n"}]}