Skip to content

Commit

Permalink
build warningのうち比較的単純なものを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
banjun committed Nov 6, 2022
1 parent 30a2c14 commit f2ce192
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion platform/mac/src/gui/CandidateCell.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ + (NSSize)focusSize:(NSSize)size {
- (id)initWithFont:(NSFont*)font {
if(self = [super init]) {
entry_ = [[NSMutableAttributedString alloc] init];
attributes_ = [[NSDictionary dictionaryWithObjectsAndKeys:
attributes_ = [[NSMutableDictionary dictionaryWithObjectsAndKeys:
font, NSFontAttributeName,
[NSColor labelColor], NSForegroundColorAttributeName,
nil]
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/src/gui/CandidateView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (void)drawRect:(NSRect)rect {
int margin = [CandidateView cellSpacing];

NSPoint offset = NSMakePoint(margin, margin);
int cellCount = [labels_ length];
NSUInteger cellCount = [labels_ length];

for(unsigned index = 0; index < [candidateCells_ count]; ++ index) {
CandidateCell* cell = [candidateCells_ objectAtIndex:index];
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/src/gui/CandidateWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
- (void)setPage:(NSRange)page;
- (void)showAt:(NSPoint)origin level:(int)level;
- (void)hide;
- (int)indexOfLabel:(char)label;
- (NSUInteger)indexOfLabel:(char)label;
- (id)newCandidateCell;

@end
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/src/gui/CandidateWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ - (void)hide {
[window_ orderOut:nil];
}

- (int)indexOfLabel:(char)label {
- (NSUInteger)indexOfLabel:(char)label {
NSString* target = [NSString stringWithFormat:@"%c", label];
NSRange result = [labels_ rangeOfString:target options:NSCaseInsensitiveSearch];

Expand Down
8 changes: 4 additions & 4 deletions platform/mac/src/preferences/DictionarySet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ @implementation DictionarySet
- (void)moveObjectsInArrangedObjectsFromIndexes:(NSIndexSet*)indexSet toIndex:(unsigned int)insertIndex {
NSArray* objects = [self arrangedObjects];
NSUInteger idx = [indexSet lastIndex];
int aboveInsertIndexCount = 0;
int removeIndex;
NSUInteger aboveInsertIndexCount = 0;
NSUInteger removeIndex;

while(NSNotFound != idx) {
if(idx >= insertIndex) {
Expand Down Expand Up @@ -102,7 +102,7 @@ - (IBAction)browseLocation:(id)sender {

- (BOOL)tableView:(NSTableView*)tv writeRowsWithIndexes:(NSIndexSet*)rowIndexes toPasteboard:(NSPasteboard*)pboard {
NSArray* typesArray = [NSArray arrayWithObjects:DictionaryRowsType, nil];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes requiringSecureCoding:YES error:nil];

[pboard declareTypes:typesArray owner:self];
[pboard setData:data forType:DictionaryRowsType];
Expand Down Expand Up @@ -141,7 +141,7 @@ - (BOOL)tableView:(NSTableView*)tv

NSPasteboard* pboard = [info draggingPasteboard];
NSData* rowData = [pboard dataForType:DictionaryRowsType];
NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:rowData];
NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSIndexSet class] fromData:rowData error:nil];

[self moveObjectsInArrangedObjectsFromIndexes:rowIndexes toIndex:row];

Expand Down
2 changes: 1 addition & 1 deletion platform/mac/src/preferences/PreferenceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ - (IBAction)showFontPanel:(id)sender {
}

- (void)keyboardLayoutDidChange:(id)sender {
int index = [layoutPopUp_ indexOfSelectedItem];
NSInteger index = [layoutPopUp_ indexOfSelectedItem];
NSString* selectedLayout = [layoutNames_ objectAtIndex:index];

if(selectedLayout) {
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/src/server/MacCandidateWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MacCandidateWindow : public SKKCandidateWindow {
NSMutableArray* candidates_;
NSRange page_;
int cursor_;
int cellCount_;
NSUInteger cellCount_;
CandidateWindow* window_;

void reloadUserDefaults();
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/src/server/MacCandidateWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}

int MacCandidateWindow::LabelIndex(char label) {
return [window_ indexOfLabel:label];
return (int)[window_ indexOfLabel:label];
}

// ------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/src/server/MacConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
int MacConfig::integerConfig(NSString* key) {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];

return [defaults integerForKey:key];
return (int)[defaults integerForKey:key];
}

bool MacConfig::boolConfig(NSString* key) {
Expand Down
7 changes: 2 additions & 5 deletions platform/mac/src/server/MacInputModeWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ CGPoint FlipPoint(int x, int y) {
}

int ActiveProcessID() {
NSDictionary* info = [[NSWorkspace sharedWorkspace] activeApplication];
NSNumber* pid = [info objectForKey:@"NSApplicationProcessIdentifier"];

return [pid intValue];
return [[NSWorkspace sharedWorkspace] frontmostApplication].processIdentifier;
}

typedef std::vector<CGRect> CGRectContainer;
Expand Down Expand Up @@ -98,7 +95,7 @@ - (void)activate:(id)sender {
CGRectContainer list = CreateWindowBoundsListOf(ActiveProcessID());

// カーソル位置がウィンドウ矩形に含まれていなければ無視する
int count = std::count_if(list.begin(), list.end(),
long count = std::count_if(list.begin(), list.end(),
std::bind2nd(std::ptr_fun(CGRectContainsPoint), cursor));
if(!count) {
return;
Expand Down
2 changes: 2 additions & 0 deletions platform/mac/src/server/SKKInputController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ - (SKKInputMode)syncInputSource {
[self changeInputMode:context_.selectedKeyboardInputSource];
return system;
}

return current;
}

- (void)cancelKeyEventForASCII {
Expand Down
4 changes: 2 additions & 2 deletions platform/mac/src/server/SKKServer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ - (void)reloadUserDefaults {
flag = [defaults boolForKey:SKKUserDefaultKeys::enable_private_mode] == YES;
SKKBackEnd::theInstance().EnablePrivateMode(flag);

int length = [defaults integerForKey:SKKUserDefaultKeys::minimum_completion_length];
SKKBackEnd::theInstance().SetMinimumCompletionLength(length);
NSInteger length = [defaults integerForKey:SKKUserDefaultKeys::minimum_completion_length];
SKKBackEnd::theInstance().SetMinimumCompletionLength((int)length);
}

- (void)reloadDictionarySet {
Expand Down
12 changes: 6 additions & 6 deletions src/engine/backend/SKKNumericConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ static std::string ConvertType3(const std::string& src) {
const char* unit1[] = { "", "", "", "", "", "" };
const char* unit2[] = { "", "", "" };
std::string result;
unsigned int previous_size = 0;
unsigned long previous_size = 0;

if(src.size() == 1 && src[0] == '0') {
return "";
}

for(unsigned i = src.find_first_not_of("0"); i < src.size(); ++ i) {
for(unsigned long i = src.find_first_not_of("0"); i < src.size(); ++ i) {
switch(src[i]) {
case '2':
result += "";
Expand Down Expand Up @@ -150,7 +150,7 @@ static std::string ConvertType3(const std::string& src) {
break;
}

int distance = src.size() - i;
unsigned long distance = src.size() - i;

// 「十、百、千」以外の位
if(distance > 4 && (distance - 1) % 4 == 0) {
Expand Down Expand Up @@ -194,13 +194,13 @@ static std::string ConvertType5(const std::string& src) {
const char* unit1[] = { "", "", "", "", "", "" };
const char* unit2[] = { "", "", "" };
std::string result;
unsigned int previous_size = 0;
unsigned long previous_size = 0;

if(src.size() == 1 && src[0] == '0') {
return "";
}

for(unsigned i = src.find_first_not_of("0"); i < src.size(); ++ i) {
for(unsigned long i = src.find_first_not_of("0"); i < src.size(); ++ i) {
switch(src[i]) {
case '1':
result += "";
Expand Down Expand Up @@ -231,7 +231,7 @@ static std::string ConvertType5(const std::string& src) {
break;
}

int distance = src.size() - i;
unsigned long distance = src.size() - i;

// 「十、百、千」以外の位
if(distance > 4 && (distance - 1) % 4 == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/completer/SKKCompleter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int SKKCompleter::minPosition() const {
}

int SKKCompleter::maxPosition() const {
return completions_.size() - 1;
return (int)(completions_.size() - 1);
}

void SKKCompleter::notify() {
Expand Down
6 changes: 3 additions & 3 deletions src/engine/dictionary/SKKHttpDictionaryLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int SKKHttpDictionaryLoader::content_length(net::socket::tcpstream& http) {
return length;
}

int SKKHttpDictionaryLoader::file_size(const std::string& path) const {
long long SKKHttpDictionaryLoader::file_size(const std::string& path) const {
struct stat st;

if(stat(path.c_str(), &st) == 0) {
Expand All @@ -128,15 +128,15 @@ bool SKKHttpDictionaryLoader::download(net::socket::tcpstream& http, int length)
}

// ダウンロードに失敗したか?
int new_size = file_size(tmp_path_);
long long new_size = file_size(tmp_path_);
if(new_size != length) {
std::cerr << "SKKHttpDictionaryLoader::download(): size conflict: expected="
<< length << ", actual=" << new_size << std::endl;
return false;
}

// 既存の辞書と比較して小さすぎないか?
int old_size = file_size(path_);
long long old_size = file_size(path_);
if(old_size != 0) {
const int safety_margin = 32 * 1024; // 32KB

Expand Down
2 changes: 1 addition & 1 deletion src/engine/dictionary/SKKHttpDictionaryLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SKKHttpDictionaryLoader : public SKKDictionaryLoader {

bool request(net::socket::tcpstream& http);
int content_length(net::socket::tcpstream& http);
int file_size(const std::string& path) const;
long long file_size(const std::string& path) const;
bool download(net::socket::tcpstream& http, int length);

public:
Expand Down
2 changes: 1 addition & 1 deletion src/engine/entry/SKKEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void SKKEntry::SetEntry(const std::string& entry) {
normal_entry_ = entry;

if(!normal_entry_.empty()) {
unsigned last_index = normal_entry_.size() - 1;
unsigned long last_index = normal_entry_.size() - 1;

// 見出し語末尾の prefix を取り除く(ex. "かk" → "か")
if(normal_entry_.find_last_of(prefix_) == last_index) {
Expand Down
4 changes: 2 additions & 2 deletions src/engine/selector/SKKWindowSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool SKKWindowSelector::Select(char label) {
}

void SKKWindowSelector::Show() {
window_->Update(view_.begin(), view_.end(), cursor_pos_, page_pos_ + 1, pages_.size());
window_->Update(view_.begin(), view_.end(), cursor_pos_, page_pos_ + 1, (int)pages_.size());
window_->Show();
}

Expand All @@ -133,7 +133,7 @@ int SKKWindowSelector::minPage() const {
}

int SKKWindowSelector::maxPage() const {
return pages_.size() - 1;
return (int)(pages_.size() - 1);
}

int SKKWindowSelector::minPosition() const {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/utility/pthreadutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace pthread {
std::deque<pthread_t> pool_;
std::deque<task*> tasks_;
bool should_terminate_;
unsigned idle_threads_;
unsigned long idle_threads_;

static void* handler(void* param) {
pool* self = reinterpret_cast<pool*>(param);
Expand Down
8 changes: 4 additions & 4 deletions src/engine/utility/socketutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ namespace socket {
}

virtual int sync() {
int remain = pptr() - pbase();
long remain = pptr() - pbase();
int offset = 0;

while(0 < remain) {
int result = ::send(fd_, pbase() + offset, remain, 0);
ssize_t result = ::send(fd_, pbase() + offset, remain, 0);
if(result == -1) return -1;

remain -= result;
Expand All @@ -342,7 +342,7 @@ namespace socket {
setg(eback(), eback(), eback());

// fill buffer
int length = ::recv(fd_, gptr(), BUFFER_SIZE, 0);
ssize_t length = ::recv(fd_, gptr(), BUFFER_SIZE, 0);
if(length == 0 || length == -1) return traits_type::eof();

setg(eback(), gptr(), gptr() + length);
Expand Down Expand Up @@ -589,7 +589,7 @@ namespace socket {
return select();
}

int wait(long seconds, long micro_seconds = 0) {
int wait(long seconds, int micro_seconds = 0) {
timeval tv;

tv.tv_sec = seconds;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/utility/subrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class subrange {
Iter end_;

void adjust(Container& container, size_type pos, size_type length) {
unsigned size = container.size();
unsigned long size = container.size();

if(pos < size) {
begin_ = container.begin() + pos;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/utility/utf8util.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct utf8 {
// if(common_prefix("1漢字2", "1漢字3") == "1漢字") { ...
//
static std::string common_prefix(const std::string&s1, const std::string& s2) {
int max = std::min(s1.size(), s2.size());
const unsigned long max = std::min(s1.size(), s2.size());
utf8::const_iterator iter1(s1.begin());
utf8::const_iterator iter2(s2.begin());

Expand Down

0 comments on commit f2ce192

Please sign in to comment.