Skip to content

Commit

Permalink
Fixed some implicit narrowing conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbooth committed Feb 20, 2020
1 parent 107d616 commit 5396892
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 45 deletions.
22 changes: 10 additions & 12 deletions CompactDisc/CompactDisc.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
* $Id$
*
* Copyright (C) 2005 - 2007 Stephen F. Booth <[email protected]>
* Copyright (C) 2005 - 2020 Stephen F. Booth <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -138,13 +136,13 @@ - (NSString *) discID

// zero is lead out
int offsets[100];
offsets[0] = [self leadOut] + 150;
offsets[0] = (int)[self leadOut] + 150;

NSUInteger i;
for(i = 0; i < [self countOfTracks]; ++i)
offsets[1 + i] = [self firstSectorForTrack:i] + 150;
offsets[1 + i] = (int)[self firstSectorForTrack:i] + 150;

int result = discid_put(discID, 1, [self countOfTracks], offsets);
int result = discid_put(discID, 1, (int)[self countOfTracks], offsets);
if(result)
musicBrainzDiscID = [NSString stringWithCString:discid_get_id(discID) encoding:NSASCIIStringEncoding];

Expand All @@ -163,13 +161,13 @@ - (NSURL *) discIDSubmissionUrl

// zero is lead out
int offsets[100];
offsets[0] = [self leadOut] + 150;
offsets[0] = (int)[self leadOut] + 150;

NSUInteger i;
for(i = 0; i < [self countOfTracks]; ++i)
offsets[1 + i] = [self firstSectorForTrack:i] + 150;
offsets[1 + i] = (int)[self firstSectorForTrack:i] + 150;

int result = discid_put(discID, 1, [self countOfTracks], offsets);
int result = discid_put(discID, 1, (int)[self countOfTracks], offsets);
if(result)
submissionUrl = [NSURL URLWithString:[NSString stringWithCString:discid_get_submission_url(discID) encoding:NSASCIIStringEncoding]];

Expand All @@ -188,13 +186,13 @@ - (NSString *) freeDBDiscID

// zero is lead out
int offsets[100];
offsets[0] = [self leadOut] + 150;
offsets[0] = (int)[self leadOut] + 150;

NSUInteger i;
for(i = 0; i < [self countOfTracks]; ++i)
offsets[1 + i] = [self firstSectorForTrack:i] + 150;
offsets[1 + i] = (int)[self firstSectorForTrack:i] + 150;

int result = discid_put(discID, 1, [self countOfTracks], offsets);
int result = discid_put(discID, 1, (int)[self countOfTracks], offsets);
if(result)
freeDBDiscID = [NSString stringWithCString:discid_get_freedb_id(discID) encoding:NSASCIIStringEncoding];

Expand Down
6 changes: 2 additions & 4 deletions Controllers/LogController.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
* $Id$
*
* Copyright (C) 2005 - 2007 Stephen F. Booth <[email protected]>
* Copyright (C) 2005 - 2020 Stephen F. Booth <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -142,7 +140,7 @@ - (IBAction) save:(id)sender
// Apply style
[logMessage addAttribute:NSFontAttributeName value:[NSFont fontWithName:@"Helvetica" size:11.0] range:NSMakeRange(0, [logMessage length])];

NSData *rtf = [logMessage RTFFromRange:NSMakeRange(0, [logMessage length]) documentAttributes:nil];
NSData *rtf = [logMessage RTFFromRange:NSMakeRange(0, [logMessage length]) documentAttributes:@{ NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType } ];

BOOL fileCreated = [[NSFileManager defaultManager] createFileAtPath:filename contents:rtf attributes:nil];
NSAssert(YES == fileCreated, NSLocalizedStringFromTable(@"Unable to create the output file.", @"Exceptions", @""));
Expand Down
4 changes: 2 additions & 2 deletions Rippers/ComparisonRipper.m
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,10 @@ - (void) ripSectorRange:(SectorRange *)range toFile:(ExtAudioFileRef)file
// Put the data in an AudioBufferList
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mData = buffer;
bufferList.mBuffers[0].mDataByteSize = [readRange byteSize];
bufferList.mBuffers[0].mDataByteSize = (UInt32)[readRange byteSize];
bufferList.mBuffers[0].mNumberChannels = 2;

frameCount = [readRange byteSize] / 4;
frameCount = (UInt32)([readRange byteSize] / 4);

// Write the data
err = ExtAudioFileWrite(file, frameCount, &bufferList);
Expand Down
38 changes: 18 additions & 20 deletions Tasks/EncoderTasks/WavPackEncoderTask.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
* $Id$
*
* Copyright (C) 2005 - 2007 Stephen F. Booth <[email protected]>
* Copyright (C) 2005 - 2020 Stephen F. Booth <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -67,35 +65,35 @@ - (void) writeTags
// Album title
album = [metadata albumTitle];
if(nil != album)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"ALBUM"] cStringUsingEncoding:NSASCIIStringEncoding], [album UTF8String], strlen([album UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"ALBUM"] cStringUsingEncoding:NSASCIIStringEncoding], [album UTF8String], (int)strlen([album UTF8String]));

// Artist
artist = [metadata trackArtist];
if(nil == artist)
artist = [metadata albumArtist];
if(nil != artist)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"ARTIST"] cStringUsingEncoding:NSASCIIStringEncoding], [artist UTF8String], strlen([artist UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"ARTIST"] cStringUsingEncoding:NSASCIIStringEncoding], [artist UTF8String], (int)strlen([artist UTF8String]));

// Composer
composer = [metadata trackComposer];
if(nil == composer)
composer = [metadata albumComposer];
if(nil != composer)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"COMPOSER"] cStringUsingEncoding:NSASCIIStringEncoding], [composer UTF8String], strlen([composer UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"COMPOSER"] cStringUsingEncoding:NSASCIIStringEncoding], [composer UTF8String], (int)strlen([composer UTF8String]));

// Genre
genre = [metadata trackGenre];
if(nil == genre)
genre = [metadata albumGenre];
if(nil != genre)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"GENRE"] cStringUsingEncoding:NSASCIIStringEncoding], [genre UTF8String], strlen([genre UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"GENRE"] cStringUsingEncoding:NSASCIIStringEncoding], [genre UTF8String], (int)strlen([genre UTF8String]));

// Year
year = [metadata trackDate];
if(nil == year)
year = [metadata albumDate];
if(nil != year)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"YEAR"] cStringUsingEncoding:NSASCIIStringEncoding], [year UTF8String], strlen([year UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"YEAR"] cStringUsingEncoding:NSASCIIStringEncoding], [year UTF8String], (int)strlen([year UTF8String]));

// Comment
comment = [metadata albumComment];
Expand All @@ -105,55 +103,55 @@ - (void) writeTags
if([[[[self taskInfo] settings] objectForKey:@"saveSettingsInComment"] boolValue])
comment = (nil == comment ? [self encoderSettingsString] : [NSString stringWithFormat:@"%@\n%@", comment, [self encoderSettingsString]]);
if(nil != comment)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"COMMENT"] cStringUsingEncoding:NSASCIIStringEncoding], [comment UTF8String], strlen([comment UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"COMMENT"] cStringUsingEncoding:NSASCIIStringEncoding], [comment UTF8String], (int)strlen([comment UTF8String]));

// Track title
title = [metadata trackTitle];
if(nil != title)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"TITLE"] cStringUsingEncoding:NSASCIIStringEncoding], [title UTF8String], strlen([title UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"TITLE"] cStringUsingEncoding:NSASCIIStringEncoding], [title UTF8String], (int)strlen([title UTF8String]));

// Track number
trackNumber = [metadata trackNumber];
if(nil != trackNumber)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"TRACK"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [trackNumber intValue]] UTF8String], strlen([[NSString stringWithFormat:@"%u", [trackNumber intValue]] UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"TRACK"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [trackNumber intValue]] UTF8String], (int)strlen([[NSString stringWithFormat:@"%u", [trackNumber intValue]] UTF8String]));

// Track total
trackTotal = [metadata trackTotal];
if(nil != trackTotal)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"TRACKTOTAL"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [trackTotal intValue]] UTF8String], strlen([[NSString stringWithFormat:@"%u", [trackTotal intValue]] UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"TRACKTOTAL"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [trackTotal intValue]] UTF8String], (int)strlen([[NSString stringWithFormat:@"%u", [trackTotal intValue]] UTF8String]));

// Disc number
discNumber = [metadata discNumber];
if(nil != discNumber)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"DISCNUMBER"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [discNumber intValue]] UTF8String], strlen([[NSString stringWithFormat:@"%u", [discNumber intValue]] UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"DISCNUMBER"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [discNumber intValue]] UTF8String], (int)strlen([[NSString stringWithFormat:@"%u", [discNumber intValue]] UTF8String]));

// Discs in set
discTotal = [metadata discTotal];
if(nil != discTotal)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"DISCTOTAL"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [discTotal intValue]] UTF8String], strlen([[NSString stringWithFormat:@"%u", [discTotal intValue]] UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"DISCTOTAL"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [discTotal intValue]] UTF8String], (int)strlen([[NSString stringWithFormat:@"%u", [discTotal intValue]] UTF8String]));

// Compilation
compilation = [metadata compilation];
if(nil != compilation)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"COMPILATION"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [compilation intValue]] UTF8String], strlen([[NSString stringWithFormat:@"%u", [compilation intValue]] UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"COMPILATION"] cStringUsingEncoding:NSASCIIStringEncoding], [[NSString stringWithFormat:@"%u", [compilation intValue]] UTF8String], (int)strlen([[NSString stringWithFormat:@"%u", [compilation intValue]] UTF8String]));

// ISRC
isrc = [metadata ISRC];
if(nil != isrc)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"ISRC"] cStringUsingEncoding:NSASCIIStringEncoding], [isrc UTF8String], strlen([isrc UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"ISRC"] cStringUsingEncoding:NSASCIIStringEncoding], [isrc UTF8String], (int)strlen([isrc UTF8String]));

// MCN
mcn = [metadata MCN];
if(nil != mcn)
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"MCN"] cStringUsingEncoding:NSASCIIStringEncoding], [mcn UTF8String], strlen([mcn UTF8String]));
WavpackAppendTagItem(wpc, [[AudioMetadata customizeWavPackTag:@"MCN"] cStringUsingEncoding:NSASCIIStringEncoding], [mcn UTF8String], (int)strlen([mcn UTF8String]));

// Encoded by
bundleVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
WavpackAppendTagItem(wpc, "TOOL NAME", "Max", strlen("Max"));
WavpackAppendTagItem(wpc, "TOOL VERSION", [bundleVersion UTF8String], strlen([bundleVersion UTF8String]));
WavpackAppendTagItem(wpc, "TOOL NAME", "Max", (int)strlen("Max"));
WavpackAppendTagItem(wpc, "TOOL VERSION", [bundleVersion UTF8String], (int)strlen([bundleVersion UTF8String]));

// Encoder settings
WavpackAppendTagItem(wpc, "ENCODING", [[self encoderSettingsString] UTF8String], strlen([[self encoderSettingsString] UTF8String]));
WavpackAppendTagItem(wpc, "ENCODING", [[self encoderSettingsString] UTF8String], (int)strlen([[self encoderSettingsString] UTF8String]));

result = WavpackWriteTag(wpc);
NSAssert(0 != result, NSLocalizedStringFromTable(@"Unable to write to the output file.", @"Exceptions", @""));
Expand Down
12 changes: 5 additions & 7 deletions Utilities/UtilityFunctions.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
* $Id$
*
* Copyright (C) 2005 - 2007 Stephen F. Booth <[email protected]>
* Copyright (C) 2005 - 2020 Stephen F. Booth <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -293,11 +291,11 @@
if(kOggStreamTypeUnknown == streamType) {
oggpack_buffer opb;
char buffer[6];
int packtype;
long packtype;
unsigned i;

memset(buffer, 0, 6);
oggpack_readinit(&opb, op.packet, op.bytes);
oggpack_readinit(&opb, op.packet, (int)op.bytes);

packtype = oggpack_read(&opb, 8);
for(i = 0; i < 6; ++i) {
Expand Down Expand Up @@ -378,7 +376,7 @@
[image unlockFocus];
}

return [bitmapRep representationUsingType:type properties:nil];
return [bitmapRep representationUsingType:type properties:@{}];
}

NSImage *
Expand Down Expand Up @@ -511,7 +509,7 @@
pathString = [NSString stringWithFormat:@"%@/%@-%.8x-XXXXXXXX.%@", directory, @"Max", sessionID, extension];
strlcpy(path, [pathString fileSystemRepresentation], MAXPATHLEN);

fd = mkstemps(path, 1 + [extension length]);
fd = mkstemps(path, 1 + (int)[extension length]);
NSCAssert1(-1 != fd, @"Unable to create a temporary file: %s", strerror(errno));

intResult = close(fd);
Expand Down

0 comments on commit 5396892

Please sign in to comment.