@@ -146,8 +146,9 @@ std::error_code swift::atomicallyWritingToFile(
146
146
if (!OS.hasValue ()) {
147
147
std::error_code error;
148
148
OS.emplace (outputPath, error, fs::F_None);
149
- if (error)
149
+ if (error) {
150
150
return error;
151
+ }
151
152
}
152
153
153
154
action (OS.getValue ());
@@ -169,8 +170,9 @@ swift::areFilesDifferent(const llvm::Twine &source,
169
170
bool allowDestinationErrors) {
170
171
namespace fs = llvm::sys::fs;
171
172
172
- if (fs::equivalent (source, destination))
173
+ if (fs::equivalent (source, destination)) {
173
174
return FileDifference::IdenticalFile;
175
+ }
174
176
175
177
OpenFileRAII sourceFile;
176
178
fs::file_status sourceStatus;
@@ -187,8 +189,9 @@ swift::areFilesDifferent(const llvm::Twine &source,
187
189
// / DifferentContents return, depending on `allowDestinationErrors`.
188
190
auto convertDestinationError = [=](std::error_code error) ->
189
191
llvm::ErrorOr<FileDifference> {
190
- if (allowDestinationErrors)
192
+ if (allowDestinationErrors){
191
193
return FileDifference::DifferentContents;
194
+ }
192
195
return error;
193
196
};
194
197
@@ -204,34 +207,39 @@ swift::areFilesDifferent(const llvm::Twine &source,
204
207
}
205
208
206
209
uint64_t size = sourceStatus.getSize ();
207
- if (size != destStatus.getSize ())
210
+ if (size != destStatus.getSize ()) {
208
211
// If the files are different sizes, they must be different.
209
212
return FileDifference::DifferentContents;
210
- if (size == 0 )
213
+ }
214
+ if (size == 0 ) {
211
215
// If both files are zero size, they must be the same.
212
216
return FileDifference::SameContents;
217
+ }
213
218
214
219
// The two files match in size, so we have to compare the bytes to determine
215
220
// if they're the same.
216
221
std::error_code sourceRegionErr;
217
222
fs::mapped_file_region sourceRegion (fs::convertFDToNativeFile (sourceFile.fd ),
218
223
fs::mapped_file_region::readonly,
219
224
size, 0 , sourceRegionErr);
220
- if (sourceRegionErr)
225
+ if (sourceRegionErr) {
221
226
return sourceRegionErr;
227
+ }
222
228
223
229
std::error_code destRegionErr;
224
230
fs::mapped_file_region destRegion (fs::convertFDToNativeFile (destFile.fd ),
225
231
fs::mapped_file_region::readonly,
226
232
size, 0 , destRegionErr);
227
233
228
- if (destRegionErr)
234
+ if (destRegionErr) {
229
235
return convertDestinationError (destRegionErr);
236
+ }
230
237
231
- if (0 == memcmp (sourceRegion.const_data (), destRegion.const_data (), size))
232
- return FileDifference::SameContents;
238
+ if (memcmp (sourceRegion.const_data (), destRegion.const_data (), size) != 0 ) {
239
+ return FileDifference::DifferentContents;
240
+ }
233
241
234
- return FileDifference::DifferentContents ;
242
+ return FileDifference::SameContents ;
235
243
}
236
244
237
245
std::error_code swift::moveFileIfDifferent (const llvm::Twine &source,
0 commit comments