From f2ce192d33e2822b5ef61a9a4543fe34db7c1373 Mon Sep 17 00:00:00 2001 From: BAN Jun Date: Sun, 6 Nov 2022 14:01:29 +0900 Subject: [PATCH] =?UTF-8?q?build=20warning=E3=81=AE=E3=81=86=E3=81=A1?= =?UTF-8?q?=E6=AF=94=E8=BC=83=E7=9A=84=E5=8D=98=E7=B4=94=E3=81=AA=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/mac/src/gui/CandidateCell.mm | 2 +- platform/mac/src/gui/CandidateView.mm | 2 +- platform/mac/src/gui/CandidateWindow.h | 2 +- platform/mac/src/gui/CandidateWindow.mm | 2 +- platform/mac/src/preferences/DictionarySet.mm | 8 ++++---- platform/mac/src/preferences/PreferenceController.mm | 2 +- platform/mac/src/server/MacCandidateWindow.h | 2 +- platform/mac/src/server/MacCandidateWindow.mm | 2 +- platform/mac/src/server/MacConfig.mm | 2 +- platform/mac/src/server/MacInputModeWindow.mm | 7 ++----- platform/mac/src/server/SKKInputController.mm | 2 ++ platform/mac/src/server/SKKServer.mm | 4 ++-- src/engine/backend/SKKNumericConverter.cpp | 12 ++++++------ src/engine/completer/SKKCompleter.cpp | 2 +- src/engine/dictionary/SKKHttpDictionaryLoader.cpp | 6 +++--- src/engine/dictionary/SKKHttpDictionaryLoader.h | 2 +- src/engine/entry/SKKEntry.cpp | 2 +- src/engine/selector/SKKWindowSelector.cpp | 4 ++-- src/engine/utility/pthreadutil.h | 2 +- src/engine/utility/socketutil.h | 8 ++++---- src/engine/utility/subrange.h | 2 +- src/engine/utility/utf8util.h | 2 +- 22 files changed, 39 insertions(+), 40 deletions(-) diff --git a/platform/mac/src/gui/CandidateCell.mm b/platform/mac/src/gui/CandidateCell.mm index 496f627c..329f0071 100644 --- a/platform/mac/src/gui/CandidateCell.mm +++ b/platform/mac/src/gui/CandidateCell.mm @@ -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] diff --git a/platform/mac/src/gui/CandidateView.mm b/platform/mac/src/gui/CandidateView.mm index 75a51254..6e605546 100644 --- a/platform/mac/src/gui/CandidateView.mm +++ b/platform/mac/src/gui/CandidateView.mm @@ -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]; diff --git a/platform/mac/src/gui/CandidateWindow.h b/platform/mac/src/gui/CandidateWindow.h index 204eac7b..c27ae943 100644 --- a/platform/mac/src/gui/CandidateWindow.h +++ b/platform/mac/src/gui/CandidateWindow.h @@ -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 diff --git a/platform/mac/src/gui/CandidateWindow.mm b/platform/mac/src/gui/CandidateWindow.mm index 8dcda9bf..f1287470 100644 --- a/platform/mac/src/gui/CandidateWindow.mm +++ b/platform/mac/src/gui/CandidateWindow.mm @@ -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]; diff --git a/platform/mac/src/preferences/DictionarySet.mm b/platform/mac/src/preferences/DictionarySet.mm index c32b29a6..a33d299a 100644 --- a/platform/mac/src/preferences/DictionarySet.mm +++ b/platform/mac/src/preferences/DictionarySet.mm @@ -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) { @@ -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]; @@ -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]; diff --git a/platform/mac/src/preferences/PreferenceController.mm b/platform/mac/src/preferences/PreferenceController.mm index a4345de3..bbf6c9a8 100644 --- a/platform/mac/src/preferences/PreferenceController.mm +++ b/platform/mac/src/preferences/PreferenceController.mm @@ -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) { diff --git a/platform/mac/src/server/MacCandidateWindow.h b/platform/mac/src/server/MacCandidateWindow.h index a4311392..8685971b 100644 --- a/platform/mac/src/server/MacCandidateWindow.h +++ b/platform/mac/src/server/MacCandidateWindow.h @@ -34,7 +34,7 @@ class MacCandidateWindow : public SKKCandidateWindow { NSMutableArray* candidates_; NSRange page_; int cursor_; - int cellCount_; + NSUInteger cellCount_; CandidateWindow* window_; void reloadUserDefaults(); diff --git a/platform/mac/src/server/MacCandidateWindow.mm b/platform/mac/src/server/MacCandidateWindow.mm index 1a95fb2a..12202504 100644 --- a/platform/mac/src/server/MacCandidateWindow.mm +++ b/platform/mac/src/server/MacCandidateWindow.mm @@ -109,7 +109,7 @@ } int MacCandidateWindow::LabelIndex(char label) { - return [window_ indexOfLabel:label]; + return (int)[window_ indexOfLabel:label]; } // ------------------------------------------------------------ diff --git a/platform/mac/src/server/MacConfig.mm b/platform/mac/src/server/MacConfig.mm index a4b784d1..2d9deee5 100644 --- a/platform/mac/src/server/MacConfig.mm +++ b/platform/mac/src/server/MacConfig.mm @@ -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) { diff --git a/platform/mac/src/server/MacInputModeWindow.mm b/platform/mac/src/server/MacInputModeWindow.mm index b7313795..fd019fdd 100644 --- a/platform/mac/src/server/MacInputModeWindow.mm +++ b/platform/mac/src/server/MacInputModeWindow.mm @@ -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 CGRectContainer; @@ -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; diff --git a/platform/mac/src/server/SKKInputController.mm b/platform/mac/src/server/SKKInputController.mm index e1fc77e1..bcaa8b37 100644 --- a/platform/mac/src/server/SKKInputController.mm +++ b/platform/mac/src/server/SKKInputController.mm @@ -398,6 +398,8 @@ - (SKKInputMode)syncInputSource { [self changeInputMode:context_.selectedKeyboardInputSource]; return system; } + + return current; } - (void)cancelKeyEventForASCII { diff --git a/platform/mac/src/server/SKKServer.mm b/platform/mac/src/server/SKKServer.mm index dcc29b5c..fbd53362 100644 --- a/platform/mac/src/server/SKKServer.mm +++ b/platform/mac/src/server/SKKServer.mm @@ -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 { diff --git a/src/engine/backend/SKKNumericConverter.cpp b/src/engine/backend/SKKNumericConverter.cpp index fe4a798a..0f6d55dd 100644 --- a/src/engine/backend/SKKNumericConverter.cpp +++ b/src/engine/backend/SKKNumericConverter.cpp @@ -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 += "二"; @@ -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) { @@ -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 += "壱"; @@ -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) { diff --git a/src/engine/completer/SKKCompleter.cpp b/src/engine/completer/SKKCompleter.cpp index 98e771d8..839993c1 100644 --- a/src/engine/completer/SKKCompleter.cpp +++ b/src/engine/completer/SKKCompleter.cpp @@ -79,7 +79,7 @@ int SKKCompleter::minPosition() const { } int SKKCompleter::maxPosition() const { - return completions_.size() - 1; + return (int)(completions_.size() - 1); } void SKKCompleter::notify() { diff --git a/src/engine/dictionary/SKKHttpDictionaryLoader.cpp b/src/engine/dictionary/SKKHttpDictionaryLoader.cpp index d7223536..b68acdb4 100644 --- a/src/engine/dictionary/SKKHttpDictionaryLoader.cpp +++ b/src/engine/dictionary/SKKHttpDictionaryLoader.cpp @@ -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) { @@ -128,7 +128,7 @@ 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; @@ -136,7 +136,7 @@ bool SKKHttpDictionaryLoader::download(net::socket::tcpstream& http, int length) } // 既存の辞書と比較して小さすぎないか? - int old_size = file_size(path_); + long long old_size = file_size(path_); if(old_size != 0) { const int safety_margin = 32 * 1024; // 32KB diff --git a/src/engine/dictionary/SKKHttpDictionaryLoader.h b/src/engine/dictionary/SKKHttpDictionaryLoader.h index 32602f37..9f4a0c4f 100644 --- a/src/engine/dictionary/SKKHttpDictionaryLoader.h +++ b/src/engine/dictionary/SKKHttpDictionaryLoader.h @@ -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: diff --git a/src/engine/entry/SKKEntry.cpp b/src/engine/entry/SKKEntry.cpp index 311560ca..0f289fdd 100644 --- a/src/engine/entry/SKKEntry.cpp +++ b/src/engine/entry/SKKEntry.cpp @@ -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) { diff --git a/src/engine/selector/SKKWindowSelector.cpp b/src/engine/selector/SKKWindowSelector.cpp index 570e2f3f..7af2a19c 100644 --- a/src/engine/selector/SKKWindowSelector.cpp +++ b/src/engine/selector/SKKWindowSelector.cpp @@ -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(); } @@ -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 { diff --git a/src/engine/utility/pthreadutil.h b/src/engine/utility/pthreadutil.h index c30a87bb..8038a9f7 100644 --- a/src/engine/utility/pthreadutil.h +++ b/src/engine/utility/pthreadutil.h @@ -259,7 +259,7 @@ namespace pthread { std::deque pool_; std::deque tasks_; bool should_terminate_; - unsigned idle_threads_; + unsigned long idle_threads_; static void* handler(void* param) { pool* self = reinterpret_cast(param); diff --git a/src/engine/utility/socketutil.h b/src/engine/utility/socketutil.h index e44710d9..7079fc7d 100644 --- a/src/engine/utility/socketutil.h +++ b/src/engine/utility/socketutil.h @@ -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; @@ -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); @@ -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; diff --git a/src/engine/utility/subrange.h b/src/engine/utility/subrange.h index d2a728fc..934a03f6 100644 --- a/src/engine/utility/subrange.h +++ b/src/engine/utility/subrange.h @@ -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; diff --git a/src/engine/utility/utf8util.h b/src/engine/utility/utf8util.h index 06de4381..5c86ebcf 100644 --- a/src/engine/utility/utf8util.h +++ b/src/engine/utility/utf8util.h @@ -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());