liuzianglib beta 2.4.2V20,20170421

liuzianglib beta 2.4.2V20,20170421

DC::IOCP::Server减少了读取文件时的内存用量；DC::IOCP::Server增加可拓展的异常处理；DC::IOCP::Server其它问题修复与改进；

--- DC_IOCP.h
+++ DC_IOCP.h
@@ -9,7 +9,7 @@
 #include "DC_ThreadPool.h"
 #include "DC_timer.h"
 #pragma comment(lib,"ws2_32.lib")
-//Version 2.4.2V19
+//Version 2.4.2V20
 //20170421

 namespace DC {
@@ -81,7 +81,7 @@

 		public:
 			inline void resetBuffer() {
-				ZeroMemory(m_wsabuf.buf, m_wsabuf.len);
+				memset(m_wsabuf.buf, NULL, m_wsabuf.len);
 			}

 			inline void CloseSock() {
@@ -122,12 +122,14 @@

 			public:
 				inline void setCleanLimit(const int32_t& input) {
+					if (this == nullptr) return;
 					if (input < 1) { cleanLimit.store(1, std::memory_order_release); return; }
 					cleanLimit.store(input, std::memory_order_release);
 				}

 				template <typename ...U>
 				inline T* make(U&& ...args)noexcept {
+					if (this == nullptr) return nullptr;
 					Cleanif();
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					try {
@@ -141,6 +143,7 @@

 				template <typename ...U>
 				inline T* put(U&& ...args)noexcept {//only unique_ptr
+					if (this == nullptr) return nullptr;
 					Cleanif();
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					try {
@@ -153,6 +156,7 @@
 				}

 				T* release(const T *input) {
+					if (this == nullptr) return nullptr;
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					for (auto i = m.begin(); i != m.end(); i++) {
 						if (*input == *(i->get())) {
@@ -164,6 +168,7 @@
 				}

 				bool drop(const T *input) {
+					if (this == nullptr) return false;
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					auto fres = std::find_if(m.begin(), m.end(), std::bind(&Pool::compare, this, std::placeholders::_1, input));

@@ -176,12 +181,14 @@
 				}

 				void clean() {
+					if (this == nullptr) return;
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					realClean();
 					removeTime.store(0, std::memory_order_release);
 				}

 				inline void clear() {
+					if (this == nullptr) return;
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					m.clear();
 					removeTime.store(0, std::memory_order_release);
@@ -220,12 +227,14 @@

 			public:
 				inline void setCleanLimit(const int32_t& input) {
+					if (this == nullptr) return;
 					if (input < 1) { cleanLimit.store(1, std::memory_order_release); return; }
 					cleanLimit.store(input, std::memory_order_release);
 				}

 				template <typename ...U>
 				inline T* make(U&& ...args)noexcept {
+					if (this == nullptr) return nullptr;
 					Cleanif();
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					try {
@@ -239,6 +248,7 @@

 				template <typename ...U>
 				inline T* put(U&& ...args)noexcept {//only unique_ptr
+					if (this == nullptr) return nullptr;
 					Cleanif();
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					try {
@@ -251,6 +261,7 @@
 				}

 				T* release(const T *input) {
+					if (this == nullptr) return nullptr;
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					for (auto i = m.begin(); i != m.end(); i++) {
 						if (*input == *(i->get())) {
@@ -262,6 +273,7 @@
 				}

 				bool drop(const T *input) {
+					if (this == nullptr) return false;
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					auto fres = std::find_if(m.begin(), m.end(), std::bind(&Pool::compare, this, std::placeholders::_1, input));

@@ -274,12 +286,14 @@
 				}

 				void clean() {
+					if (this == nullptr) return;
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					realClean();
 					removeTime.store(0, std::memory_order_release);
 				}

 				inline void clear() {
+					if (this == nullptr) return;
 					std::unique_lock<std::mutex> LwriteLock(writeLock);
 					m.clear();
 					removeTime.store(0, std::memory_order_release);
@@ -368,28 +382,42 @@

 		class Server {
 		public:
-			Server(const std::size_t& inputThreadNumber) :TP(nullptr), ThreadNumber(inputThreadNumber), m_listen(INVALID_SOCKET), m_iocp(nullptr), PoolCleanLimit(1), CleanTimeInterval(1), stopFlag(true) {}
+			Server(const std::size_t& inputThreadNumber) :TP(nullptr), ThreadNumber(inputThreadNumber), m_listen(INVALID_SOCKET), m_iocp(nullptr), PoolCleanLimit(1), CleanTimeInterval(1), stopFlag(true) {
+				//Ĭ
+				SetMemoryPoolCleanLimit(20);//ڴش
+				SetCleanTimeInterval(60);//̻߳Ѽ()
+				SetConnectionMaxLiveTime(30);//ͻʱ()
+			}

 			Server(const Server&) = delete;

 			virtual ~Server()noexcept {
-				Stop();
-			}
-
-		public:
-			static inline bool LoadSocketLib() {
-				return WinSock::Startup(2, 2);
-			}
-
-			static inline void UnloadSocketLib() {
-				WinSock::Cleanup();
-			}
-
-			inline void SetListenAddr(const WinSock::Address& input) {
+				try {
+					Stop();
+				}
+				catch (...) {}//Ըڴй©ҲҪδΪ
+			}
+
+		public:
+			static inline bool LoadSocketLib()noexcept {
+				try {
+					return WinSock::Startup(2, 2);
+				}
+				catch (...) { return false; }
+			}
+
+			static inline void UnloadSocketLib()noexcept {
+				try {
+					WinSock::Cleanup();
+				}
+				catch (...) {}
+			}
+
+			inline void SetListenAddr(const WinSock::Address& input)noexcept {
 				bindAddr = input;
 			}

-			inline void SetListenAddr(const std::string& ip, const int32_t& port) {
+			inline void SetListenAddr(const std::string& ip, const int32_t& port)noexcept {
 				bindAddr = WinSock::MakeAddr(ip, port);
 			}

@@ -406,13 +434,22 @@
 				ConnectionTimeOut.store(input, std::memory_order_release);
 			}

-			bool Start(int32_t waitlimit) {
-				m_iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
-				if (m_iocp == NULL || m_iocp == nullptr) return false;
+			bool Start(int32_t waitlimit = 1) {//Զεãִ
+				try {
+					Stop();
+				}
+				catch (...) { return false; }
+
 				if (waitlimit < 1) waitlimit = 1;
-				TP = new DC::ThreadPool(ThreadNumber + 2);//cleanerlistener
+
+				if (isNull(m_iocp))
+					m_iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
+				if (isNull(m_iocp)) return false;
+
+				if (isNull(TP))
+					TP = new DC::ThreadPool(ThreadNumber + 2);//cleanerlistener
 				TP->start();
-
+
 				auto wait = TP->async(&Server::ListenerThread, this);
 				if (wait.wait_for(std::chrono::seconds(waitlimit)) != std::future_status::timeout)
 					return false;
@@ -426,27 +463,33 @@
 				return true;
 			}

-			inline void Stop() {
+			inline void Stop() {//Զεãִ
+                //̷ֹ߳ͣź
+				std::vector<DC::IOCP::PICptr> temp;
+				for (int i = 0; i < ThreadNumber; i++)
+					temp.emplace_back(new(std::nothrow) DC::IOCP::PerIOContext(1));
+				for (auto& p : temp)
+					PostExit(p.get());
+
 				//ֹͣ
-				closesocket(m_listen);
+				if (m_listen != INVALID_SOCKET)
+					closesocket(m_listen);
+
 				//̷ֹ߳ͣź
 				stopFlag.store(true, std::memory_order_release);
 				cleanerCV.notify_all();
-				//̷ֹ߳ͣź
-				std::vector<DC::IOCP::PICptr> temp;
-				for (int i = 0; i < ThreadNumber; i++)
-					temp.emplace_back(new DC::IOCP::PerIOContext(getSendBufferSize()));
-				for (auto& p : temp)
-					PostExit(p.get());
+
 				//رɶ˿
-				if (m_iocp != nullptr&&m_iocp != NULL) { CloseHandle(m_iocp); m_iocp = nullptr; }
+				if (!isNull(m_iocp)) { CloseHandle(m_iocp); m_iocp = nullptr; }
+
 				//رղɾ̳߳
-				if (TP != nullptr) { delete TP; TP = nullptr; }
+				if (!isNull(TP)) { delete TP; TP = nullptr; }
+
 				//տͻSOCKET
 				PSC_Pool.clear();
 			}

-			static inline void loop() {//Զ᷵
+			static inline void loop()noexcept {//Զ᷵
 				while (true)
 					std::this_thread::sleep_for(std::chrono::minutes(9710));
 			}
@@ -456,20 +499,20 @@
 				return 1024;
 			}

-			virtual inline const std::size_t getSendBufferSize()noexcept {//send
-				return 1024;
-			}
-
-			virtual void OnRecv(DC::IOCP::PerSocketContext *PSC, const std::string& recvstr, const DC::WinSock::Address& ClientAddr) {}
-
-			virtual void OnSend(DC::IOCP::PerSocketContext *PSC, const std::string& sendstr, const DC::WinSock::Address& ClientAddr) {}
-
-			inline bool Send(PerSocketContext *client, const std::string& sendthis) {
-				return PostSend(client, client->make(getSendBufferSize()), sendthis);
+			virtual void OnRecv(DC::IOCP::PerSocketContext*, const std::string&, const DC::WinSock::Address&) {}
+
+			virtual void OnSend(DC::IOCP::PerSocketContext*, const std::string&, const DC::WinSock::Address&) {}
+
+			virtual void OnError(const DC::DC_ERROR&) {}
+
+			inline bool Send(PerSocketContext *client, const std::string& sendthis)noexcept {
+				return PostSend(client, client->make(sendthis.size() + 1), sendthis);
 			}

 		private:
-			bool PostRecv(PerSocketContext *PSC, PerIOContext *PIC) {
+			bool PostRecv(PerSocketContext *PSC, PerIOContext *PIC)noexcept {
+				if (isNull(PSC) || isNull(PIC)) return false;
+
 				DWORD dwFlags = 0;
 				DWORD dwBytes = 0;

@@ -485,12 +528,25 @@
 				return true;
 			}

-			inline bool DoRecv(PerSocketContext *PSC, PerIOContext *PIC) {
-				OnRecv(PSC, PIC->m_wsabuf.buf, PSC->m_clientAddr);
+			inline bool DoRecv(PerSocketContext *PSC, PerIOContext *PIC)noexcept {
+				if (isNull(PSC) || isNull(PIC)) return false;
+
+				try {
+					OnRecv(PSC, PIC->m_wsabuf.buf, PSC->m_clientAddr);
+				}
+				catch (const DC::DC_ERROR& err) {
+					this->OnError(err);
+				}
+				catch (...) {
+					this->OnError(DC::DC_ERROR("OnRecv", "uncaught exception", -1));
+				}
+
 				return PostRecv(PSC, PIC);
 			}

-			bool PostSend(PerSocketContext *PSC, PerIOContext *PIC, const std::string& sendthis) {
+			bool PostSend(PerSocketContext *PSC, PerIOContext *PIC, const std::string& sendthis)noexcept {
+				if (isNull(PSC) || isNull(PIC)) return false;
+
 				DWORD dwFlags = 0;
 				DWORD dwBytes = sendthis.size();

@@ -509,12 +565,24 @@
 				return true;
 			}

-			inline bool DoSend(PerSocketContext *PSC, PerIOContext *PIC) {
-				OnSend(PSC, PIC->m_wsabuf.buf, PSC->m_clientAddr);
-				if (!PSC->drop(PIC)) throw DC_ERROR("DoSend", "", -1);
-			}
-
-			inline bool PostExit(PerIOContext *PIC) {
+			inline bool DoSend(PerSocketContext *PSC, PerIOContext *PIC)noexcept {
+				if (isNull(PSC) || isNull(PIC)) return false;
+
+				try {
+					OnSend(PSC, PIC->m_wsabuf.buf, PSC->m_clientAddr);
+					PSC->drop(PIC);
+				}
+				catch (const DC::DC_ERROR& err) {
+					this->OnError(err);
+				}
+				catch (...) {
+					this->OnError(DC::DC_ERROR("OnSend", "uncaught exception", -1));
+				}
+			}
+
+			inline bool PostExit(PerIOContext *PIC)noexcept {
+				if (isNull(PIC)) return false;
+
 				PerIOContext *AcceptIoContext = PIC;
 				DWORD dwBytes = 0;
 				AcceptIoContext->m_opType = OperationType::NULL_POSTED;
@@ -523,7 +591,7 @@
 				return false;
 			}

-			void WorkerThread() {
+			void WorkerThread()noexcept {
 				DWORD dwBytesTransfered = 0;
 				OVERLAPPED *pOverlapped = NULL;
 				PerSocketContext *pSocketContext = NULL;
@@ -532,10 +600,12 @@
 					BOOL GQrv = GetQueuedCompletionStatus(m_iocp, &dwBytesTransfered,
 						reinterpret_cast<PULONG_PTR>(&pSocketContext), &pOverlapped, INFINITE);

-					if (NULL == pSocketContext) break;
-					if (!GQrv) {//˴
-						continue;
-					}
+					//PSCΪ(һζɶ˿ѹر)
+					if (isNull(pSocketContext)) break;
+					//ɶ˿ѹر
+					if (isNull(m_iocp)) break;
+					//˴
+					if (!GQrv) continue;

 					PerIOContext *pIOContext = CONTAINING_RECORD(pOverlapped, PerIOContext, m_overlapped);

@@ -545,14 +615,15 @@
 					}

 					switch (pIOContext->m_opType) {
-					case OperationType::ACCEPT_POSTED: {}break;
 					case OperationType::RECV_POSTED: {
 						DoRecv(pSocketContext, pIOContext);
 					}break;
 					case OperationType::SEND_POSTED: {
 						DoSend(pSocketContext, pIOContext);
 					}break;
-					case OperationType::NULL_POSTED: {return; }break;
+					case OperationType::NULL_POSTED: {
+						return;
+					}break;
 					}
 				}
 			}
@@ -571,66 +642,74 @@
 					acceptSocket = INVALID_SOCKET;
 					if (!DC::WinSock::Accept(acceptSocket, m_listen, ClientAddr)) { closesocket(m_listen); return false; }

-					PSCptr ptr(new PerSocketContext(PoolCleanLimit.load(std::memory_order_acquire)));
+					PSCptr ptr(new(std::nothrow) PerSocketContext(PoolCleanLimit.load(std::memory_order_acquire)));
+					if (!ptr) { closesocket(acceptSocket); continue; }//newʧ
 					ptr->m_sock = acceptSocket;
 					ptr->m_clientAddr = ClientAddr;
-					if (!AssociateWithIOCP(ptr.get())) continue;
-					if (!PostRecv(ptr.get(), ptr->make(getRecvBufferSize()))) continue;
-					PSC_Pool.put(std::move(ptr));
+					if (!AssociateWithIOCP(ptr.get())) { closesocket(acceptSocket); continue; }//󶨵ɶ˿ʧ
+					if (!PostRecv(ptr.get(), ptr->make(getRecvBufferSize()))) { closesocket(acceptSocket); continue; }//PostRecvʧ
+					if (nullptr == PSC_Pool.put(std::move(ptr))) { closesocket(acceptSocket); continue; }//¼ͻʧ
 				}

 				return true;
 			}

-			void CleanerThread(const std::chrono::seconds limits) {
-				//std::cout << "cleanerʼ\n";
-				DC::timer timer;
-				std::chrono::seconds templimits;
-				while (true) {
-					templimits = limits;
-					timer.reset();
-					timer.start();
-					//std::cout << "cleaner\n";
-					std::unique_lock<std::mutex> lock(cleanerMut);
+			void CleanerThread(const std::chrono::seconds limits)noexcept {
+				try {
+					DC::timer timer;
+					std::chrono::seconds templimits;
 					while (true) {
-						if (cleanerCV.wait_for(lock, templimits) == std::cv_status::timeout)
-							if (stopFlag == true)
-							{
-								//std::cout << "cleaner˳\n";
-								return;
-							}
-							else//
-								break;
-						timer.stop();
-						if (std::chrono::seconds(timer.getsecond()) >= templimits)
-							if (stopFlag == true)//滽
-							{
-								//std::cout << "cleaner˳\n";
-								return;
-							}
-							else//ٻ
-								break;
-						//ٻ
-						templimits = templimits - std::chrono::seconds(timer.getsecond());
+						templimits = limits;
 						timer.reset();
 						timer.start();
-					}
-					//std::cout << "cleaner\n";
-
-					std::unique_lock<std::mutex> lockPSC(PSC_Pool.writeLock);
-					for (auto& p : PSC_Pool.m) {
-						if (p.get() == nullptr) continue;
-						if (p->getTimerSeconds() >= ConnectionTimeOut.load(std::memory_order_acquire)) {
-							p->CloseSock();
-							PSC_Pool.drop_nolock(p.get());
+						std::unique_lock<std::mutex> lock(cleanerMut);
+						while (true) {
+							if (cleanerCV.wait_for(lock, templimits) == std::cv_status::timeout)
+								if (stopFlag.load(std::memory_order_acquire) == true)
+									return;//˳ź
+								else
+									break;//ʱ䵽ʼ
+
+							timer.stop();
+
+							if (stopFlag.load(std::memory_order_acquire) == true)
+								return;//˳ź
+
+							if (std::chrono::seconds(timer.getsecond()) >= templimits)
+								break;//˯ͷ
+
+							//ٻѣʣʱ俪ʼһֵȴ
+							templimits = templimits - std::chrono::seconds(timer.getsecond());
+							timer.reset();
+							timer.start();
 						}
-					}
-					lockPSC.unlock();
-					PSC_Pool.clean();
-				}
-			}
-
-			inline bool AssociateWithIOCP(PerSocketContext* input) {
+
+						std::unique_lock<std::mutex> lockPSC(PSC_Pool.writeLock);
+						for (auto& p : PSC_Pool.m) {
+							if (p.get() == nullptr) continue;
+							if (p->getTimerSeconds() >= ConnectionTimeOut.load(std::memory_order_acquire)) {
+								p->CloseSock();
+								PSC_Pool.drop_nolock(p.get());
+							}
+						}
+						lockPSC.unlock();
+						PSC_Pool.clean();
+					}
+				}
+				//쳣Ļֱ˳
+				catch (const DC_ERROR& err) {
+					OnError(err);
+					return;
+				}
+				catch (...) {
+					OnError(DC::DC_ERROR("CleanerThread", "uncaught exception", -1));
+					return;
+				}
+			}
+
+			inline bool AssociateWithIOCP(PerSocketContext* input)noexcept {
+				if (isNull(input)) return false;
+
 				HANDLE hTemp = CreateIoCompletionPort(reinterpret_cast<HANDLE>(input->m_sock), m_iocp, reinterpret_cast<DWORD>(input), 0);

 				if (NULL == hTemp)
@@ -638,7 +717,13 @@
 				return true;
 			}

-		protected:
+			template <typename T>
+			inline bool isNull(T ptr)noexcept {
+				if (ptr == nullptr || ptr == NULL) return true;
+				return false;
+			}
+
+		private:
 			HANDLE m_iocp;
 			SOCKET m_listen;
 			ThreadPool *TP;


scripting console expands on multi-line paste

--- ui/scriptingconsole.h
+++ ui/scriptingconsole.h
@@ -9,6 +9,7 @@
 #include <QtWidgets/QDialog>
 #include <QtWidgets/QListView>
 #include <QtCore/QAbstractListModel>
+#include <QtCore/QMimeData>
 #include <mutex>
 #include <string>
 #include <utility>
@@ -82,6 +83,8 @@
 	void setCharHeight(int height);
 	void setContinutation(bool cont);
 	void setCompletionCallback(CompletionCallback callback) { m_completionCallback = callback; }
+	void insertFromMimeData(const QMimeData * source) override;
+

 private Q_SLOTS:
 	void complete(QString text);


undid jpff "reverted mod"

undid jpff "reverted mod"

--- Opcodes/partikkel.c
+++ Opcodes/partikkel.c
@@ -421,7 +421,7 @@

         /* check if waveform gets zero volume. if so, let's mark it as unused
          * and move on to the next one */
-        if (fabs(curwav->gain) < 1e-10) {
+        if (fabs(curwav->gain) < FL(1e-10)) {
             curwav->table = NULL;
             continue;
         }


Fix bug in sub-sample grain placement when using grain rate FM.

--- Opcodes/partikkel.c
+++ Opcodes/partikkel.c
@@ -295,6 +295,8 @@
     p->fmampindex = 0;
     p->distindex = 0;
     p->synced = 0;
+    p->graininc = 0.0;
+
     /* allocate memory for the grain mix buffer */
     size = csound->ksmps*sizeof(MYFLT);
     if (p->aux.auxp == NULL || p->aux.size < size)
@@ -529,7 +531,7 @@
     int32 n;
     NODE *node;
     MYFLT **waveformparams = &p->waveform1;
-    MYFLT grainfreq = *p->grainfreq;
+    MYFLT grainfreq = fabs(*p->grainfreq);

     /* krate table lookup, first look up waveform ftables */
     for (n = 0; n < 4; ++n) {
@@ -548,10 +550,6 @@

     /* start grain scheduling */
     for (n = 0; n < csound->ksmps; ++n) {
-        if (p->grainfreq_arate)
-            grainfreq = p->grainfreq[n];
-        p->graininc = fabs(grainfreq*csound->onedsr);
-
         if (p->sync[n] >= FL(1.0)) {
             /* we got a full sync pulse, hardsync grain clock if needed */
             if (!p->synced) {
@@ -602,7 +600,7 @@
                 offset = 10.;
             else
                 offset = (offset - p->grainphase)/grainfreq;
-            /* prepare actual grain creation */
+
             /* check if there are any grains left in the pool */
             if (!p->gpool.free_nodes) {
                 if (!p->out_of_voices_warning) {
@@ -629,6 +627,10 @@
         /* store away the scheduler phase for use in partikkelsync */
         if (p->globals_entry)
             p->globals_entry->synctab[csound->ksmps + n] = p->grainphase;
+
+        if (p->grainfreq_arate)
+            grainfreq = fabs(p->grainfreq[n]);
+        p->graininc = grainfreq*csound->onedsr;
         p->grainphase += p->graininc;
     }
     return OK;


bump to build number 10.0.0.76

bump to build number 10.0.0.76

--- event_mon.c
+++ event_mon.c
@@ -25,7 +25,7 @@
 #include <string.h>
 #include "sdc_sdk.h"

-#define LRD_BLD_NUMBER  "10.0.0.75"
+#define LRD_BLD_NUMBER  "10.0.0.76"

 #define LRD_EVENT_MON_VERSION_MAJOR 3
 #define LRD_EVENT_MON_VERSION_MINOR 5


Remove unnecessary assert

Remove unnecessary assert

--- OpenAL32/alBuffer.c
+++ OpenAL32/alBuffer.c
@@ -321,8 +321,6 @@
                                         ((format==AL_FORMAT_REAR16) ? 2 :
                                          4));

-                    assert(aluBytesFromFormat(NewFormat) == 2);
-
                     if((size%(OrigBytes*2)) != 0)
                     {
                         alSetError(Context, AL_INVALID_VALUE);


[SCSI] aic79xx: fix sense_buffer access bug

The commit de25deb18016f66dcdede165d07654559bb332bc changed
scsi_cmnd.sense_buffer from a static array to a dynamically allocated
buffer. We can't access to sense_buffer in '&cmd->sense_buffer' way.

Signed-off-by: FUJITA Tomonori <93dac1fe9c4b2a3957982200319981492ad4976e@lab.ntt.co.jp>
Signed-off-by: James Bottomley <407b36959ca09543ccda8f8e06721c791bc53435@HansenPartnership.com>

--- drivers/scsi/aic7xxx/aic79xx_osm.c
+++ drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -1922,7 +1922,7 @@
 				struct scsi_sense_data *sense;

 				sense = (struct scsi_sense_data *)
-					&cmd->sense_buffer;
+					cmd->sense_buffer;
 				if (sense->extra_len >= 5 &&
 				    (sense->add_sense_code == 0x47
 				     || sense->add_sense_code == 0x48))


Fix a bunch of comments

Fix a bunch of comments

--- OpenAL32/alBuffer.c
+++ OpenAL32/alBuffer.c
@@ -102,10 +102,10 @@
 };

 /*
-*    alGenBuffers(ALsizei n, ALuint *puiBuffers)
-*
-*    Generates n AL Buffers, and stores the Buffers Names in the array pointed to by puiBuffers
-*/
+ *    alGenBuffers(ALsizei n, ALuint *buffers)
+ *
+ *    Generates n AL Buffers, and stores the Buffers Names in the array pointed to by buffers
+ */
 AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
 {
     ALCcontext *Context;
@@ -153,10 +153,10 @@
 }

 /*
-*    alDeleteBuffers(ALsizei n, ALuint *puiBuffers)
-*
-*    Deletes the n AL Buffers pointed to by puiBuffers
-*/
+ *    alDeleteBuffers(ALsizei n, ALuint *buffers)
+ *
+ *    Deletes the n AL Buffers pointed to by buffers
+ */
 AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
 {
     ALCcontext *Context;
@@ -183,10 +183,9 @@
             if(!buffers[i])
                 continue;

-            /* Check for valid Buffer ID (can be NULL buffer) */
+            /* Check for valid Buffer ID */
             if((ALBuf=LookupBuffer(device->BufferMap, buffers[i])) == NULL)
             {
-                // Invalid Buffer
                 alSetError(Context, AL_INVALID_NAME);
                 Failed = AL_TRUE;
                 break;
@@ -225,10 +224,10 @@
 }

 /*
-*    alIsBuffer(ALuint uiBuffer)
-*
-*    Checks if ulBuffer is a valid Buffer Name
-*/
+ *    alIsBuffer(ALuint buffer)
+ *
+ *    Checks if buffer is a valid Buffer Name
+ */
 AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer)
 {
     ALCcontext *Context;
@@ -246,10 +245,10 @@
 }

 /*
-*    alBufferData(ALuint buffer,ALenum format,ALvoid *data,ALsizei size,ALsizei freq)
-*
-*    Fill buffer with audio data
-*/
+ *    alBufferData(ALuint buffer,ALenum format,const ALvoid *data,ALsizei size,ALsizei freq)
+ *
+ *    Fill buffer with audio data
+ */
 AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *data,ALsizei size,ALsizei freq)
 {
     ALCcontext *Context;
@@ -278,7 +277,7 @@

     device = Context->Device;
     if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
-        alSetError(Context, AL_INVALID_NAME); /* Invalid Buffer Name */
+        alSetError(Context, AL_INVALID_NAME);
     else if(size < 0 || freq < 0)
         alSetError(Context, AL_INVALID_VALUE);
     else if(ALBuf->refcount != 0)
@@ -377,9 +376,10 @@
             ALuint NewBytes = aluBytesFromFormat(NewFormat);
             ALuint64 newsize, allocsize;

-            // Here is where things vary:
-            // nVidia and Apple use 64+1 samples per channel per block => block_size=36*chans bytes
-            // Most PC sound software uses 2040+1 samples per channel per block -> block_size=1024*chans bytes
+            /* Here is where things vary:
+             * nVidia and Apple use 64+1 sample frames per block => block_size=36*chans bytes
+             * Most PC sound software uses 2040+1 sample frames per block -> block_size=1024*chans bytes
+             */
             if((size%(36*Channels)) != 0)
             {
                 alSetError(Context, AL_INVALID_VALUE);
@@ -519,10 +519,10 @@
 }

 /*
-*    alBufferSubDataSOFT(ALuint buffer,ALenum format,ALvoid *data,ALsizei offset,ALsizei length)
-*
-*    Fill buffer with audio data
-*/
+ *    alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length)
+ *
+ *    Update buffer's audio data
+ */
 AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length)
 {
     ALCcontext *Context;
@@ -1041,9 +1041,10 @@
  * LoadData
  *
  * Loads the specified data into the buffer, using the specified formats.
- * Currently, the new format must be 32-bit float, and must have the same
- * channel configuration as the original format. This does NOT handle
- * compressed formats (eg. IMA4).
+ * Currently, the new format must have the same channel configuration as the
+ * original format, and must have the same sample format (except for double,
+ * which converts to float). This does NOT handle compressed formats (eg. IMA4
+ * and muLaw).
  */
 static ALenum LoadData(ALbuffer *ALBuf, const ALvoid *data, ALsizei size, ALuint freq, ALenum OrigFormat, ALenum NewFormat)
 {
@@ -1064,7 +1065,6 @@
     if((size%(OrigBytes*OrigChannels)) != 0)
         return AL_INVALID_VALUE;

-    // Allocate extra padding samples
     newsize = size / OrigBytes;
     allocsize = (BUFFER_PADDING*NewChannels + newsize)*NewBytes;
     if(allocsize > INT_MAX)
@@ -1248,10 +1248,10 @@
 }

 /*
-*    ReleaseALBuffers()
-*
-*    INTERNAL FN : Called by DLLMain on exit to destroy any buffers that still exist
-*/
+ *    ReleaseALBuffers()
+ *
+ *    INTERNAL FN : Called by alcCloseDevice to destroy any buffers that still exist
+ */
 ALvoid ReleaseALBuffers(ALCdevice *device)
 {
     ALsizei i;


optimize DHT timing sequence stat

optimize DHT timing sequence stat

--- DHT/DHT.c
+++ DHT/DHT.c
@@ -12,9 +12,6 @@
 #define DHT_GPIO_HIGH HIGH
 #define DHT_GPIO_LOW LOW

-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-
 typedef enum {
     DHT11   = 11,
     DHT21   = 21,
@@ -34,14 +31,14 @@
 int DHT_read(DHT_Type type, uint8_t pin, float* humidity, float* temperature)
 {
     int count;
-    int stat_wait_ACK_start[2] = {9999,0};
-    int stat_ACK_width[2] = {9999,0};
-    int stat_data_start_width[2] = {9999,0};
-    int stat_bit_start_width[2] = {9999,0};
-    int stat_bit_width[2] = {9999,0};
+    int wait_ack_count;
+    int ack_count;
+    int data_ready_count;
+    int bit_start_count[40];
+    int bit_level_count[40];
     int bit;
-    char sum;
-    char data[5] = {0,0,0,0,0};
+    unsigned char sum;
+    unsigned char data[5] = {0,0,0,0,0};

     // Send the activate pulse
     // Step 1: MCU send out start signal to DHT22 and DHT22 send
@@ -49,58 +46,52 @@
     // If always signal high-voltage-level, it means DHT22 is not
     // working properly, plesee check the electrical connection status.
     DHT_GPIO_OUTPUT;
-    DHT_wait_ms(1); //18 milliseconds
+    DHT_wait_us(10); //20 us
     DHT_GPIO_CLR; //MCU send out start signal to DHT22
-    DHT_wait_ms(1); //18 ms
+    DHT_wait_ms(1); //1 ms
     DHT_GPIO_SET; //MCU pull up
-    DHT_wait_us(40); //40us
+    DHT_wait_us(10); //20us
     DHT_GPIO_INPUT;
     //DHT_GPIO_PUDUP;

     // Find the start of the ACK Pulse
     count = 0;
-    do
+    while(DHT_GPIO_READ == DHT_GPIO_HIGH)     // Exit on DHT22 pull low within 80us
     {
         if (count++ > 10)
-	{     // (Spec is 80 us, 40*2 == 80us
+	{
             fprintf(stderr,"not present ACK start\n");
             return DHT_ERROR_NOT_PRESENT;;
         }
         DHT_wait_us(2);
     }
-    while(DHT_GPIO_READ == DHT_GPIO_HIGH);     // Exit on DHT22 pull low within 80us
-    stat_wait_ACK_start[0] = MIN(stat_wait_ACK_start[0], count);
-    stat_wait_ACK_start[1] = MAX(stat_wait_ACK_start[1], count);
+    wait_ack_count = count;

     // Find the last of the ACK Pulse
     count = 0;
-    do
+    while(DHT_GPIO_READ == DHT_GPIO_LOW)     // Exit on DHT22 pull High within 80us
     {
         if (count++ > 40)
-	{     // (Spec is 80 us, 40*2 == 80us
+	{
             fprintf(stderr,"not present ACK last\n");
             return DHT_ERROR_NOT_PRESENT;;
         }
         DHT_wait_us(2);
     }
-    while(DHT_GPIO_READ == DHT_GPIO_LOW);     // Exit on DHT22 pull High within 80us
-    stat_ACK_width[0] = MIN(stat_ACK_width[0], count);
-    stat_ACK_width[1] = MAX(stat_ACK_width[1], count);
+    ack_count = count;

     // wait DHT pull low to sent the first bit.
     count = 0;
-    do
+    while(DHT_GPIO_READ == DHT_GPIO_HIGH)     // Exit on DHT22 pull low  within 80us
     {
         if (count++ > 50)
-	{     // (Spec is 80 us, 40*2 == 80us
+	{
             fprintf(stderr,"no data sent\n");
             return DHT_ERROR_NOT_PRESENT;;
         }
         DHT_wait_us(2);
     }
-    while(DHT_GPIO_READ == DHT_GPIO_HIGH);     // Exit on DHT22 pull low  within 80us
-    stat_data_start_width[0] = MIN(stat_data_start_width[0], count);
-    stat_data_start_width[1] = MAX(stat_data_start_width[1], count);
+    data_ready_count = count;

     // Reading the 40 bit data stream
@@ -112,34 +103,30 @@
     {
         // Getting start bit signal
         count = 0;
-        do
+	while(DHT_GPIO_READ == DHT_GPIO_LOW)        // Exit on high volage within 50us
 	{
             if (count++ > 40)
-	    {     // Spec is 50 us, 25*2 == 50us
+	    {
                 fprintf(stderr,"bit %d start timeout\n", bit);
                 return DHT_ERROR_TIMEOUT;
             }
             DHT_wait_us(2);
         }
-	while(DHT_GPIO_READ == DHT_GPIO_LOW);        // Exit on high volage within 50us
-	stat_bit_start_width[0] = MIN(stat_bit_start_width[0], count);
-	stat_bit_start_width[1] = MAX(stat_bit_start_width[1], count);
+	bit_start_count[bit] = count;

         // Measure the width of the data pulse
         count = 0;
-        do
+	while(DHT_GPIO_READ == DHT_GPIO_HIGH)        // Exit on high volage within 50us
 	{
             if (count++ > 50)
-	    {     // Spec is 80 us, 40*2 == 80us
+	    {
                 fprintf(stderr,"bit %d width timeout\n", bit);
                 return DHT_ERROR_TIMEOUT;
             }
             DHT_wait_us(2);
         }
-	while(DHT_GPIO_READ == DHT_GPIO_HIGH);        // Exit on high volage within 50us
-	stat_bit_width[0] = MIN(stat_bit_width[0], count);
-	stat_bit_width[1] = MAX(stat_bit_width[1], count);
-
+	bit_level_count[bit] = count;
+
         if(count > 20)
 	{
 	    // connt > 20 is a 1(20*2 = 40us)
@@ -156,16 +143,14 @@
     }
     else
     {
-        fprintf(stderr, "wait ACK %d %d\n",
-	        stat_wait_ACK_start[0], stat_wait_ACK_start[1]);
-        fprintf(stderr, "ACK width %d %d\n",
-	        stat_ACK_width[0], stat_ACK_width[1]);
-        fprintf(stderr, "data start %d %d\n",
-	        stat_data_start_width[0], stat_data_start_width[1]);
-        fprintf(stderr, "bit start %d %d\n",
-	        stat_bit_start_width[0], stat_bit_start_width[1]);
-        fprintf(stderr, "bit width %d %d\n",
-	        stat_bit_width[0], stat_bit_width[1]);
+        fprintf(stderr, "wait ack   %2d\n", wait_ack_count);
+        fprintf(stderr, "ack        %2d\n", ack_count);
+        fprintf(stderr, "data ready %2d\n", data_ready_count);
+	for (bit = 0; bit < 40; bit++)
+	{
+            fprintf(stderr, "bit %2d start %2d level %2d\n",
+	            bit, bit_start_count[bit], bit_level_count[bit]);
+        }
     }

     switch(type)
@@ -208,7 +193,8 @@
     }

     DHT_Error ret = DHT_read(type, pin, &humidity, &temperature);
-    if (ret != DHT_ERROR_NONE){
+    if (ret != DHT_ERROR_NONE)
+    {
         bcm2835_close();
         return(1);
     }
@@ -223,3 +209,4 @@

     return(0);
 }
+


cxgb4i: handle non-pdu-aligned rx data

cxgb4i: handle non-pdu-aligned rx data

Abort the connection upon receiving of cpl_rx_data, which means the pdu cannot
be recovered from the tcp stream. This generally is due to pdu header
corruption.

Signed-off-by: Karen Xie <1b08c48383c1f854263962314570f7dfb58ce4b7@chelsio.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


ARC: Fix __udelay calculation

ARC: Fix __udelay calculation

commit 7efd0da2d17360e1cef91507dbe619db0ee2c691 upstream.

Cast usecs to u64, to ensure that the (usecs * 4295 * HZ)
multiplication is 64 bit.

Initially, the (usecs * 4295 * HZ) part was done as a 32 bit
multiplication, with the result casted to 64 bit. This led to some bits
falling off, causing a "DMA initialization error" in the stmmac Ethernet
driver, due to a premature timeout.

Signed-off-by: Mischa Jonker <17dd7bf52eefcca323aba1679f480e7f18d70ddd@synopsys.com>
Signed-off-by: Vineet Gupta <af669d95a4c0de051445d4cafdbb2c5c4a2838be@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- arch/arc/include/asm/delay.h
+++ arch/arc/include/asm/delay.h
@@ -53,11 +53,10 @@
 {
 	unsigned long loops;

-	/* (long long) cast ensures 64 bit MPY - real or emulated
+	/* (u64) cast ensures 64 bit MPY - real or emulated
 	 * HZ * 4295 is pre-evaluated by gcc - hence only 2 mpy ops
 	 */
-	loops = ((long long)(usecs * 4295 * HZ) *
-		 (long long)(loops_per_jiffy)) >> 32;
+	loops = ((u64) usecs * 4295 * HZ * loops_per_jiffy) >> 32;

 	__delay(loops);
 }


staging: sb105x: move dereference under IS_ERR() check

Avoid dereverencing the ERR_PTR() by shifting the dereference down a
couple lines.

Signed-off-by: Dan Carpenter <ff341aa343d564f9e53e9dcb6996be8c04859a66@oracle.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>


ARM: hisi: rename smp_prepares_cpus function

As hix5hd2 and hip01 has the same .smp_prepare_cpus
in struct smp_operations, so rename hix5hd2_smp_prepare_cpus
to hisi_common_smp_prepare_cpus.

the hip01 will use hisi_common_smp_prepare_cpus in its
struct smp_operations.

Signed-off-by: Wang Long <e68b6ff438429ca41648c25d0f54e970cf858504@huawei.com>
Signed-off-by: Wei Xu <d5b9d34db6547fc7f7ae2de079a18e5c56ec917e@hisilicon.com>
Signed-off-by: Olof Johansson <8c69ee23f3f44f8162a64d579c1fa25c2f55298a@lixom.net>

--- arch/arm/mach-hisi/platsmp.c
+++ arch/arm/mach-hisi/platsmp.c
@@ -96,7 +96,7 @@
 #endif
 };

-static void __init hix5hd2_smp_prepare_cpus(unsigned int max_cpus)
+static void __init hisi_common_smp_prepare_cpus(unsigned int max_cpus)
 {
 	hisi_enable_scu_a9();
 }
@@ -125,7 +125,7 @@

 struct smp_operations hix5hd2_smp_ops __initdata = {
-	.smp_prepare_cpus	= hix5hd2_smp_prepare_cpus,
+	.smp_prepare_cpus	= hisi_common_smp_prepare_cpus,
 	.smp_boot_secondary	= hix5hd2_boot_secondary,
 #ifdef CONFIG_HOTPLUG_CPU
 	.cpu_die		= hix5hd2_cpu_die,


target/pscsi: Fix page increment

target/pscsi: Fix page increment

The page++ is wrong. It makes bio_add_pc_page() pointing to a wrong page
address if the 'while (len > 0 && data_len > 0) { ... }' loop is
executed more than one once.

Signed-off-by: Asias He <7487d0432e24c09ba3f2ff7de44b9eb030d5ae18@redhat.com>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>
Signed-off-by: Nicholas Bellinger <978acd1567d5598152161fdf8bf3ca568f950c9b@linux-iscsi.org>


pretty print in dmesg

pretty print in dmesg

--- arch/arm/sa11x0/sa11x0_ost.c
+++ arch/arm/sa11x0/sa11x0_ost.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: sa11x0_ost.c,v 1.3 2005/01/04 02:08:41 drahn Exp $ */
+/*	$OpenBSD: sa11x0_ost.c,v 1.4 2005/01/11 21:00:17 deraadt Exp $ */
 /*	$NetBSD: sa11x0_ost.c,v 1.11 2003/07/15 00:24:51 lukem Exp $	*/

 /*
@@ -246,7 +246,7 @@
 	profhz = stathz;
 	saost_sc->sc_statclock_step = TIMER_FREQUENCY / stathz;

-	printf("clock: hz=%d stathz = %d\n", hz, stathz);
+	printf("clock: hz=%d stathz=%d\n", hz, stathz);

 	/* Use the channels 0 and 1 for hardclock and statclock, respectively */
 	saost_sc->sc_clock_count = TIMER_FREQUENCY / hz;


usb: chipidea: ci13xxx_imx: check if 'data->phy_np' is not NULL

Similarly as it is done in ci13xxx_imx_remove(), only calls of_node_put if
data->phy_np is not NULL.

Signed-off-by: Fabio Estevam <679188261afeb60eb822cd934fd7b46a48ddd743@freescale.com>
Signed-off-by: Alexander Shishkin <0125b3d2989cefbb754a245b989e89659aa67db8@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>


cris build fixes: fix crisksyms.c

cris build fixes: fix crisksyms.c

- Add __negdi2 to exported symbols.
- Remove string functions from exported symbols.

Signed-off-by: Jesper Nilsson <987a7dbc972893e93e5578401bedc3a0f2ccb5e3@axis.com>
Acked-by: Mikael Starvik <6c4d7924b92058127b0499322f0d64063fb5d591@axis.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- arch/cris/kernel/crisksyms.c
+++ arch/cris/kernel/crisksyms.c
@@ -27,25 +27,13 @@
 extern void __ashldi3(void);
 extern void __ashrdi3(void);
 extern void __lshrdi3(void);
+extern void __negdi2(void);
 extern void iounmap(volatile void * __iomem);

 /* Platform dependent support */
 EXPORT_SYMBOL(kernel_thread);
 EXPORT_SYMBOL(get_cmos_time);
 EXPORT_SYMBOL(loops_per_usec);
-
-/* String functions */
-EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(strstr);
-EXPORT_SYMBOL(strcpy);
-EXPORT_SYMBOL(strchr);
-EXPORT_SYMBOL(strcmp);
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strcat);
-EXPORT_SYMBOL(strncat);
-EXPORT_SYMBOL(strncmp);
-EXPORT_SYMBOL(strncpy);

 /* Math functions */
 EXPORT_SYMBOL(__Udiv);
@@ -55,6 +43,7 @@
 EXPORT_SYMBOL(__ashldi3);
 EXPORT_SYMBOL(__ashrdi3);
 EXPORT_SYMBOL(__lshrdi3);
+EXPORT_SYMBOL(__negdi2);

 /* Memory functions */
 EXPORT_SYMBOL(__ioremap);
@@ -84,4 +73,4 @@
 EXPORT_SYMBOL(del_fast_timer);
 EXPORT_SYMBOL(schedule_usleep);
 #endif
-
+EXPORT_SYMBOL(csum_partial);


USB: usb-storage: unusual_devs entry for Oracom MP3 player

This patch (as1034) was written by Leonid Petrov, reported by Robert
Spitzenpfeil, and updated by me.  It adds an unusual_devs entry with
the IGNORE_RESIDUE flag for the Oracom MP3 player.  Together with the
change to the Get-Max-LUN routine in as1032, it makes the player usable.

Signed-off-by: Alan Stern <75ea6bb7bfc1186f92d26164de5f9268c9a45b59@rowland.harvard.edu>
Signed-off-by: Phil Dibowitz <e888d2bd6f13f82caa51a37c03d034c76f661ba3@ipom.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/usb/storage/unusual_devs.h
+++ drivers/usb/storage/unusual_devs.h
@@ -1424,6 +1424,17 @@
 		US_SC_DEVICE, US_PR_DEVICE, NULL,
 		US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64),

+/* Patch by Leonid Petrov mail at lpetrov.net
+ * Reported by Robert Spitzenpfeil <robert@spitzenpfeil.org>
+ * http://www.qbik.ch/usb/devices/showdev.php?id=1705
+ * Updated to 103 device by MJ Ray mjr at phonecoop.coop
+ */
+UNUSUAL_DEV(  0x0f19, 0x0103, 0x0100, 0x0100,
+		"Oracom Co., Ltd",
+		"ORC-200M",
+		US_SC_DEVICE, US_PR_DEVICE, NULL,
+		US_FL_IGNORE_RESIDUE ),
+
 /* David Kuehling <dvdkhlng@gmx.de>:
  * for MP3-Player AVOX WSX-300ER (bought in Japan).  Reports lots of SCSI
  * errors when trying to write.


UAPI: Make FRV use asm-generic/param.h

Make FRV use the generic settings to be found in asm-generic/param.h where
possible rather than defining its own as they're mostly exactly the same.

This sorts out a problem with HZ being redefined after the UAPI split.

Signed-off-by: David Howells <ebac1d06c1688626821bb0e574a037a7a5354e49@redhat.com>

--- arch/frv/include/asm/param.h
+++ arch/frv/include/asm/param.h
@@ -1,22 +1,8 @@
 #ifndef _ASM_PARAM_H
 #define _ASM_PARAM_H

-#ifdef __KERNEL__
-#define HZ		CONFIG_HZ	/* Internal kernel timer frequency */
-#define USER_HZ		100		/* .. some user interfaces are in "ticks" */
-#define CLOCKS_PER_SEC	(USER_HZ)	/* like times() */
-#endif
-
-#ifndef HZ
-#define HZ 100
-#endif
-
 #define EXEC_PAGESIZE	16384

-#ifndef NOGROUP
-#define NOGROUP		(-1)
-#endif
-
-#define MAXHOSTNAMELEN		64	/* max length of hostname */
+#include <asm-generic/param.h>

 #endif /* _ASM_PARAM_H */


xenbus: Support multiple grants ring with 64KB

The PV ring may use multiple grants and expect them to be mapped
contiguously in the virtual memory.

Although, the current code is relying on a Linux page will be mapped to
a single grant. On build where Linux is using a different page size than
the grant (i.e other than 4KB), the grant will always be mapped on the
first 4KB of each Linux page which make the final ring not contiguous in
the memory.

This can be fixed by mapping multiple grant in a same Linux page.

Signed-off-by: Julien Grall <2fe41d4e32b0bb991f63b975f2bed08c1e666665@citrix.com>
Signed-off-by: David Vrabel <b9d45bd1f671e508cd8daa63dfc3cabb597562df@citrix.com>


conn: fix ELASTO_DATA_CB data_out acquisition

elasto_conn_send_prepare_read_data() was incorrectly filtering out
ELASTO_DATA_CB types. Fix this.

Signed-off-by: David Disseldorp <589a549dc9f982d9f46aeeb82a09ab6d87ccf1d8@suse.de>

--- lib/conn.c
+++ lib/conn.c
@@ -551,7 +551,8 @@
 	}

 	if ((req_data->type != ELASTO_DATA_IOV)
-	 && (req_data->type != ELASTO_DATA_FILE)) {
+	 && (req_data->type != ELASTO_DATA_FILE)
+	 && (req_data->type != ELASTO_DATA_CB)) {
 		ret = -EINVAL;	/* unsupported */
 		goto err_out;
 	}


Do not call posix_fallocate() when expsize == 0.

--- lib/copy.c
+++ lib/copy.c
@@ -165,7 +165,8 @@
 	}

 #ifdef HAVE_POSIX_FALLOCATE
-	ret = posix_fallocate(fd_out, 0, expsize);
+	if (expsize != 0)
+		ret = posix_fallocate(fd_out, 0, expsize);
 #endif

 #ifdef HAVE_POSIX_FADVISE


ldap_get_certificate(): check returned value of malloc()

--- src/mappers/ldap_mapper.c
+++ src/mappers/ldap_mapper.c
@@ -751,6 +751,11 @@
 		DBG1("number auf usercertificates = %d", certcnt);

 		ldap_x509 = malloc(sizeof(X509*) * certcnt );
+		if (NULL == ldap_x509)
+		{
+			DBG("not enough memory");
+			return(-7);
+		}

 		rv = 0;
 		while(rv < certcnt )


When shutting down, don't try to restart dict processes.

--- src/master/dict-process.c
+++ src/master/dict-process.c
@@ -194,6 +194,7 @@
 		io_remove(&listener->io);
 	if (close(listener->fd) < 0)
 		i_error("close(dict listener) failed: %m");
+	listener->fd = -1;

 	/* don't try to free the dict processes here,
 	   let dict_process_destroyed() do it to avoid "unknown child exited"
@@ -209,7 +210,7 @@
 	struct dict_listener *listener = process->listener;

 	dict_process_deinit(process);
-	if (listener->processes == NULL) {
+	if (listener->processes == NULL && listener->fd != -1) {
 		/* last listener died, create new ones */
 		listener->io = io_add(listener->fd, IO_READ,
 				      dict_listener_input, listener);


* modules/codec/ffmpeg/postprocess.c: Fixed post-processing.

--- modules/codec/ffmpeg/postprocess.c
+++ modules/codec/ffmpeg/postprocess.c
@@ -111,6 +111,8 @@
     /* ***** Load post processing if enabled ***** */
     var_Get( p_dec, "ffmpeg-pp-q", &val );
     var_Set( p_dec, "ffmpeg-pp-q", val_orig );
+    if( val_orig.i_int )
+        *pb_pp = VLC_TRUE;

     return p_sys;
 }


B - bug fixes

B - bug fixes

--- 5_General/general.h
+++ 5_General/general.h
@@ -23,7 +23,7 @@
 void test_generate_lattice();
 void test_H();

-print_scalar(const COMPLEX scalar);
-print_scalar(const COMPLEX scalar, const std::string name);
+void print_scalar(const COMPLEX scalar);
+void print_scalar(const COMPLEX scalar, const std::string name);

 #endif


laod: add explicit casts to suppress warnings

--- lib/load.c
+++ lib/load.c
@@ -53,7 +53,7 @@
     grn_vector_add_element(ctx,
                            &(loader->error_messages),
                            ctx->errbuf,
-                           strlen(ctx->errbuf),
+                           (uint32_t)strlen(ctx->errbuf),
                            0,
                            GRN_DB_TEXT);
   }
@@ -157,17 +157,29 @@
   }

   void *value;
-  grn_id id = grn_hash_get(ctx, loader->columns, name, name_length, &value);
+  grn_id id = grn_hash_get(ctx,
+                           loader->columns,
+                           name,
+                           (unsigned int)name_length,
+                           &value);
   if (id != GRN_ID_NIL) {
     return *((grn_obj **)value);
   }

-  grn_obj *column = grn_obj_column(ctx, loader->table, name, name_length);
+  grn_obj *column = grn_obj_column(ctx,
+                                   loader->table,
+                                   name,
+                                   (uint32_t)name_length);
   if (!column) {
     return NULL;
   }

-  id = grn_hash_add(ctx, loader->columns, name, name_length, &value, NULL);
+  id = grn_hash_add(ctx,
+                    loader->columns,
+                    name,
+                    (unsigned int)name_length,
+                    &value,
+                    NULL);
   grn_memcpy(value, &column, sizeof(grn_obj *));
   grn_obj *range = grn_ctx_at(ctx, DB_OBJ(column)->range);
   if (grn_obj_is_table(ctx, range)) {
@@ -301,7 +313,7 @@
     grn_vector_add_element_float(ctx,
                                  vector,
                                  GRN_BULK_HEAD(key),
-                                 GRN_BULK_VSIZE(key),
+                                 (uint32_t)GRN_BULK_VSIZE(key),
                                  GRN_FLOAT32_VALUE(&weight_buffer),
                                  key->header.domain);
   }
@@ -363,7 +375,7 @@
         grn_vector_add_element_float(ctx,
                                      &values,
                                      GRN_TEXT_VALUE(element),
-                                     GRN_TEXT_LEN(element),
+                                     (uint32_t)GRN_TEXT_LEN(element),
                                      0.0,
                                      element->header.domain);
       } else {
@@ -447,7 +459,7 @@
       grn_vector_add_element(ctx,
                              &vector,
                              GRN_TEXT_VALUE(element),
-                             GRN_TEXT_LEN(element),
+                             (uint32_t)GRN_TEXT_LEN(element),
                              0,
                              range_id);
     } else {
@@ -538,7 +550,7 @@
         grn_vector_add_element_float(ctx,
                                      &values,
                                      GRN_TEXT_VALUE(element),
-                                     GRN_TEXT_LEN(element),
+                                     (uint32_t)GRN_TEXT_LEN(element),
                                      0.0,
                                      element->header.domain);
       } else {
@@ -660,7 +672,7 @@
 }

 static grn_inline int
-name_equal(const char *p, unsigned int size, const char *name)
+name_equal(const char *p, size_t size, const char *name)
 {
   if (strlen(name) != size) { return 0; }
   if (*p != GRN_DB_PSEUDO_COLUMN_PREFIX) { return 0; }
@@ -678,7 +690,8 @@

   for (; value < value_end; value = values_next(ctx, value)) {
     const char *name = data->current.column_name = GRN_TEXT_VALUE(value);
-    uint32_t name_size = data->current.column_name_size = GRN_TEXT_LEN(value);
+    size_t name_size = GRN_TEXT_LEN(value);
+    data->current.column_name_size = (uint32_t)name_size;
     value++;
     data->current.value = value;
     if (name_equal(name, name_size, GRN_COLUMN_NAME_ID) ||
@@ -688,12 +701,12 @@
     }
     grn_obj *column =
       data->current.column =
-      grn_obj_column(ctx, data->table, name, name_size);
+      grn_obj_column(ctx, data->table, name, (uint32_t)name_size);
     if (!column) {
       GRN_DEFINE_NAME(data->table);
       ERR(GRN_INVALID_ARGUMENT,
           "[table][load][%.*s] nonexistent column: <%.*s>",
-          name_size, name,
+          (int)name_size, name,
           (int)(data->current.column_name_size),
           data->current.column_name);
       grn_loader_on_column_set(ctx, loader, data);
@@ -736,7 +749,7 @@
     data->id = GRN_UINT32_VALUE(value);
     break;
   case GRN_DB_INT32 :
-    data->id = GRN_INT32_VALUE(value);
+    data->id = (grn_id)GRN_INT32_VALUE(value);
     break;
   default :
     {
@@ -790,7 +803,7 @@
     }

     const char *name = GRN_TEXT_VALUE(value);
-    unsigned int name_size = GRN_TEXT_LEN(value);
+    size_t name_size = GRN_TEXT_LEN(value);
     value = values_next(ctx, value);
     if (name_equal(name, name_size, GRN_COLUMN_NAME_ID)) {
       if (id_bulk || key) {
@@ -925,7 +938,7 @@
     }

     const char *column_name = GRN_TEXT_VALUE(value);
-    uint32_t column_name_size = GRN_TEXT_LEN(value);
+    size_t column_name_size = GRN_TEXT_LEN(value);
     if (name_equal(column_name, column_name_size, GRN_COLUMN_NAME_ID)) {
       if (loader->id_offset != -1 || loader->key_offset != -1) {
         /* _id and _key must not appear more than once. */
@@ -948,7 +961,7 @@
         loader->columns_status = GRN_LOADER_COLUMNS_BROKEN;
         return;
       }
-      loader->id_offset = i;
+      loader->id_offset = (int32_t)i;
     } else if (name_equal(column_name, column_name_size, GRN_COLUMN_NAME_KEY)) {
       if (loader->table->header.type == GRN_TABLE_NO_KEY) {
         GRN_DEFINE_NAME(loader->table);
@@ -972,7 +985,7 @@
         loader->columns_status = GRN_LOADER_COLUMNS_BROKEN;
         return;
       }
-      loader->key_offset = i;
+      loader->key_offset = (int32_t)i;
     }
     grn_obj *column = grn_loader_get_column(ctx,
                                             loader,
@@ -983,7 +996,7 @@
       ERR(GRN_INVALID_ARGUMENT,
           "[table][load][%.*s] nonexistent column: <%.*s>",
           name_size, name,
-          column_name_size, column_name);
+          (int)column_name_size, column_name);
       grn_loader_save_error(ctx, loader);
       loader->columns_status = GRN_LOADER_COLUMNS_BROKEN;
       return;
@@ -1040,7 +1053,8 @@
       }
     }
     data->current.column_name = column_only_name;
-    data->current.column_name_size = name_size - (column_only_name - name);
+    data->current.column_name_size =
+      (uint32_t)(name_size - (column_only_name - name));
     data->current.value = value;

     if (value->header.domain == GRN_JSON_LOAD_OPEN_BRACKET) {
@@ -1099,7 +1113,7 @@
   if (loader->id_offset != -1) {
     grn_obj *id_bulk = grn_loader_bracket_get(ctx,
                                               bracket_value,
-                                              loader->id_offset);
+                                              (uint32_t)(loader->id_offset));
     grn_loader_parse_id_value(ctx, loader, data, id_bulk);
     if (ctx->rc != GRN_SUCCESS) {
       return;
@@ -1140,7 +1154,7 @@
   grn_obj *bracket_value = values + begin;
   GRN_ASSERT(bracket_value->header.domain == GRN_JSON_LOAD_OPEN_BRACKET);
   GRN_UINT32_SET(ctx, bracket_value, loader->values_size - begin - 1);
-  uint32_t depth = GRN_UINT32_VECTOR_SIZE(&(loader->level));
+  size_t depth = GRN_UINT32_VECTOR_SIZE(&(loader->level));
   if (depth > loader->emit_level) {
     return;
   }
@@ -1183,7 +1197,7 @@
   grn_obj *brace_value = values + begin;
   GRN_ASSERT(brace_value->header.domain == GRN_JSON_LOAD_OPEN_BRACE);
   GRN_UINT32_SET(ctx, brace_value, loader->values_size - begin - 1);
-  uint32_t depth = GRN_UINT32_VECTOR_SIZE(&(loader->level));
+  size_t depth = GRN_UINT32_VECTOR_SIZE(&(loader->level));
   if (depth > loader->emit_level) {
     return;
   }
@@ -1221,7 +1235,7 @@
 } while (0)

 static void
-json_read(grn_ctx *ctx, grn_loader *loader, const char *str, unsigned int str_len)
+json_read(grn_ctx *ctx, grn_loader *loader, const char *str, size_t str_len)
 {
   const char *const beg = str;
   char c;
@@ -1244,7 +1258,7 @@
         break;
       default :
         ERR(GRN_INVALID_ARGUMENT,
-            "JSON must start with '[' or '{': <%.*s>", str_len, beg);
+            "JSON must start with '[' or '{': <%.*s>", (int)str_len, beg);
         loader->stat = GRN_LOADER_END;
         break;
       }
@@ -1448,13 +1462,13 @@
       switch (c) {
       case '0' : case '1' : case '2' : case '3' : case '4' :
       case '5' : case '6' : case '7' : case '8' : case '9' :
-        loader->unichar = (c - '0') * 0x1000;
+        loader->unichar = (uint32_t)((c - '0') * 0x1000);
         break;
       case 'a' : case 'b' : case 'c' : case 'd' : case 'e' : case 'f' :
-        loader->unichar = (c - 'a' + 10) * 0x1000;
+        loader->unichar = (uint32_t)((c - 'a' + 10) * 0x1000);
         break;
       case 'A' : case 'B' : case 'C' : case 'D' : case 'E' : case 'F' :
-        loader->unichar = (c - 'A' + 10) * 0x1000;
+        loader->unichar = (uint32_t)((c - 'A' + 10) * 0x1000);
         break;
       default :
         ;// todo : error
@@ -1466,13 +1480,13 @@
       switch (c) {
       case '0' : case '1' : case '2' : case '3' : case '4' :
       case '5' : case '6' : case '7' : case '8' : case '9' :
-        loader->unichar += (c - '0') * 0x100;
+        loader->unichar += (uint32_t)((c - '0') * 0x100);
         break;
       case 'a' : case 'b' : case 'c' : case 'd' : case 'e' : case 'f' :
-        loader->unichar += (c - 'a' + 10) * 0x100;
+        loader->unichar += (uint32_t)((c - 'a' + 10) * 0x100);
         break;
       case 'A' : case 'B' : case 'C' : case 'D' : case 'E' : case 'F' :
-        loader->unichar += (c - 'A' + 10) * 0x100;
+        loader->unichar += (uint32_t)((c - 'A' + 10) * 0x100);
         break;
       default :
         ;// todo : error
@@ -1484,13 +1498,13 @@
       switch (c) {
       case '0' : case '1' : case '2' : case '3' : case '4' :
       case '5' : case '6' : case '7' : case '8' : case '9' :
-        loader->unichar += (c - '0') * 0x10;
+        loader->unichar += (uint32_t)((c - '0') * 0x10);
         break;
       case 'a' : case 'b' : case 'c' : case 'd' : case 'e' : case 'f' :
-        loader->unichar += (c - 'a' + 10) * 0x10;
+        loader->unichar += (uint32_t)((c - 'a' + 10) * 0x10);
         break;
       case 'A' : case 'B' : case 'C' : case 'D' : case 'E' : case 'F' :
-        loader->unichar += (c - 'A' + 10) * 0x10;
+        loader->unichar += (uint32_t)((c - 'A' + 10) * 0x10);
         break;
       default :
         ;// todo : error
@@ -1502,13 +1516,13 @@
       switch (c) {
       case '0' : case '1' : case '2' : case '3' : case '4' :
       case '5' : case '6' : case '7' : case '8' : case '9' :
-        loader->unichar += (c - '0');
+        loader->unichar += (uint32_t)(c - '0');
         break;
       case 'a' : case 'b' : case 'c' : case 'd' : case 'e' : case 'f' :
-        loader->unichar += (c - 'a' + 10);
+        loader->unichar += (uint32_t)(c - 'a' + 10);
         break;
       case 'A' : case 'B' : case 'C' : case 'D' : case 'E' : case 'F' :
-        loader->unichar += (c - 'A' + 10);
+        loader->unichar += (uint32_t)(c - 'A' + 10);
         break;
       default :
         ;// todo : error
@@ -1525,20 +1539,23 @@
           u = 0x10000 + (loader->unichar_hi - 0xd800) * 0x400 + u - 0xdc00;
         }
         if (u < 0x80) {
-          GRN_TEXT_PUTC(ctx, loader->last, u);
+          GRN_TEXT_PUTC(ctx, loader->last, (char)u);
         } else {
           if (u < 0x800) {
-            GRN_TEXT_PUTC(ctx, loader->last, (u >> 6) | 0xc0);
+            GRN_TEXT_PUTC(ctx, loader->last, (char)((u >> 6) | 0xc0));
           } else {
             if (u < 0x10000) {
-              GRN_TEXT_PUTC(ctx, loader->last, (u >> 12) | 0xe0);
+              GRN_TEXT_PUTC(ctx, loader->last, (char)((u >> 12) | 0xe0));
             } else {
-              GRN_TEXT_PUTC(ctx, loader->last, (u >> 18) | 0xf0);
-              GRN_TEXT_PUTC(ctx, loader->last, ((u >> 12) & 0x3f) | 0x80);
+              GRN_TEXT_PUTC(ctx, loader->last,
+                            (char)((u >> 18) | 0xf0));
+              GRN_TEXT_PUTC(ctx, loader->last,
+                            (char)(((u >> 12) & 0x3f) | 0x80));
             }
-            GRN_TEXT_PUTC(ctx, loader->last, ((u >> 6) & 0x3f) | 0x80);
+            GRN_TEXT_PUTC(ctx, loader->last,
+                          (char)(((u >> 6) & 0x3f) | 0x80));
           }
-          GRN_TEXT_PUTC(ctx, loader->last, (u & 0x3f) | 0x80);
+          GRN_TEXT_PUTC(ctx, loader->last, (char)((u & 0x3f) | 0x80));
         }
       }
       loader->stat = GRN_LOADER_STRING;
@@ -1566,14 +1583,14 @@
   const char *ptr = str, *ptr_end = ptr + str_size, *rest;
   const char *tokens[256], *token_end;
   while (ptr < ptr_end) {
-    int i, n = grn_tokenize(ptr, ptr_end - ptr, tokens, 256, &rest);
+    int i, n = grn_tokenize(ptr, (size_t)(ptr_end - ptr), tokens, 256, &rest);
     for (i = 0; i < n; i++) {
       grn_obj *column;
       token_end = tokens[i];
       while (ptr < token_end && (' ' == *ptr || ',' == *ptr)) {
         ptr++;
       }
-      if (name_equal(ptr, token_end - ptr, GRN_COLUMN_NAME_ID)) {
+      if (name_equal(ptr, (size_t)(token_end - ptr), GRN_COLUMN_NAME_ID)) {
         if (loader->id_offset != -1 || loader->key_offset != -1) {
           /* _id and _key must not appear more than once. */
           if (loader->id_offset != -1) {
@@ -1590,7 +1607,9 @@
           return ctx->rc;
         }
         loader->id_offset = i;
-      } else if (name_equal(ptr, token_end - ptr, GRN_COLUMN_NAME_KEY)) {
+      } else if (name_equal(ptr,
+                            (size_t)(token_end - ptr),
+                            GRN_COLUMN_NAME_KEY)) {
         if (loader->id_offset != -1 || loader->key_offset != -1) {
           /* _id and _key must not appear more than once. */
           if (loader->id_offset != -1) {
@@ -1608,7 +1627,10 @@
         }
         loader->key_offset = i;
       }
-      column = grn_loader_get_column(ctx, loader, ptr, token_end - ptr);
+      column = grn_loader_get_column(ctx,
+                                     loader,
+                                     ptr,
+                                     (size_t)(token_end - ptr));
       if (!column) {
         ERR(GRN_INVALID_ARGUMENT, "nonexistent column: <%.*s>",
             (int)(token_end - ptr), ptr);
@@ -1648,14 +1670,18 @@
   if (input->table.length > 0) {
     grn_ctx_loader_clear(ctx);
     loader->input_type = input->type;
-    if (grn_db_check_name(ctx, input->table.value, input->table.length)) {
+    if (grn_db_check_name(ctx,
+                          input->table.value,
+                          (unsigned int)(input->table.length))) {
       GRN_DB_CHECK_NAME_ERR("[table][load]",
                             input->table.value,
                             (int)(input->table.length));
       loader->stat = GRN_LOADER_END;
       return;
     }
-    loader->table = grn_ctx_get(ctx, input->table.value, input->table.length);
+    loader->table = grn_ctx_get(ctx,
+                                input->table.value,
+                                (int)(input->table.length));
     if (!loader->table) {
       ERR(GRN_INVALID_ARGUMENT,
           "nonexistent table: <%.*s>",
@@ -1665,10 +1691,11 @@
       return;
     }
     if (input->columns.length > 0) {
-      grn_rc rc = grn_loader_parse_columns(ctx,
-                                           loader,
-                                           input->columns.value,
-                                           input->columns.length);
+      grn_rc rc =
+        grn_loader_parse_columns(ctx,
+                                 loader,
+                                 input->columns.value,
+                                 (unsigned int)(input->columns.length));
       if (rc != GRN_SUCCESS) {
         loader->columns_status = GRN_LOADER_COLUMNS_BROKEN;
         loader->stat = GRN_LOADER_END;
@@ -1683,8 +1710,10 @@
         grn_expr_parse(ctx,
                        loader->ifexists,
                        input->if_exists.value,
-                       input->if_exists.length,
-                       NULL, GRN_OP_EQUAL, GRN_OP_AND,
+                       (unsigned int)(input->if_exists.length),
+                       NULL,
+                       GRN_OP_EQUAL,
+                       GRN_OP_AND,
                        GRN_EXPR_SYNTAX_SCRIPT|GRN_EXPR_ALLOW_UPDATE);
       }
     }
@@ -1692,10 +1721,13 @@
       grn_obj *v;
       GRN_EXPR_CREATE_FOR_QUERY(ctx, loader->table, loader->each, v);
       if (loader->each && v) {
-        grn_expr_parse(ctx, loader->each,
+        grn_expr_parse(ctx,
+                       loader->each,
                        input->each.value,
-                       input->each.length,
-                       NULL, GRN_OP_EQUAL, GRN_OP_AND,
+                       (unsigned int)(input->each.length),
+                       NULL,
+                       GRN_OP_EQUAL,
+                       GRN_OP_AND,
                        GRN_EXPR_SYNTAX_SCRIPT|GRN_EXPR_ALLOW_UPDATE);
       }
     }
@@ -1787,13 +1819,13 @@
          (int)GRN_TEXT_LEN(&buffer),
          GRN_TEXT_VALUE(&buffer));
   printf("  values:[\n");
-  uint32_t n_values = GRN_BULK_VSIZE(&(loader->values)) / sizeof(grn_obj);
-  uint32_t i;
+  size_t n_values = GRN_BULK_VSIZE(&(loader->values)) / sizeof(grn_obj);
+  size_t i;
   for (i = 0; i < n_values; i++) {
     grn_obj *value = ((grn_obj *)GRN_BULK_HEAD(&(loader->values))) + i;
     GRN_BULK_REWIND(&buffer);
     grn_inspect(ctx, &buffer, value);
-    printf("    %d: %.*s,\n",
+    printf("    %" GRN_FMT_SIZE ": %.*s,\n",
            i,
            (int)GRN_TEXT_LEN(&buffer),
            GRN_TEXT_VALUE(&buffer));


remove some cruft

remove some cruft

git-svn-id: f2acecaac6fbd5a03f3d4799db58dda434111981@17915 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- lnet-lite/lnet/router.c
+++ lnet-lite/lnet/router.c
@@ -304,9 +304,6 @@
         CDEBUG(D_NET, "Add route: net %s hops %u gw %s\n",
                libcfs_net2str(net), hops, libcfs_nid2str(gateway));

-        CWARN("Add route: net %s hops %u gw %s\n",
-               libcfs_net2str(net), hops, libcfs_nid2str(gateway));
-
         if (gateway == LNET_NID_ANY ||
             LNET_NETTYP(LNET_NIDNET(gateway)) == LOLND ||
             net == LNET_NIDNET(LNET_NID_ANY) ||
@@ -1264,21 +1261,4 @@
         return rc;
 }

-/*
-void
-lnet_free_rtrpools (void)
-{
-}
-
-void
-lnet_init_rtrpools (void)
-{
-}
-
-int
-lnet_alloc_rtrpools (__unusedx int im_a_router)
-{
-        return 0;
-}
-*/
 #endif


Handle negation

Handle negation

--- rouziclib/interpreter/expression.c
+++ rouziclib/interpreter/expression.c
@@ -82,47 +82,74 @@
 		max_depth = MAXN(max_depth, depth);

 		// Try to read operators
-		if (cant_be_operator==0 && isalnum(p[0]) == 0)
+		if (isalnum(p[0]) == 0)
 		{
 			n = 0;
 			sscanf(p, "%32[-+*/%%%^=<>!]%n", name, &n);
-			if (n)
-			{
-				bufprintf(comp_log, "Operator %s, %d chars\n", name, n);
+
+			if (cant_be_operator==0)
+			{
+				if (n)
+				{
+					bufprintf(comp_log, "Operator %s, %d chars\n", name, n);
+					sym[is].type = sym_operator;
+
+					switch (p[0])
+					{
+						case '^':	// covers both ^ and ^-
+							sym[is].operator_priority = 4;
+							n = 1;
+							if (p[1] == '-')
+								n = 2;
+							break;
+						case '*':
+						case '/':
+						case '%':
+							sym[is].operator_priority = 3;
+							n = 1;
+							break;
+						case '+':
+						case '-':
+							sym[is].operator_priority = 2;
+							n = 1;
+							break;
+						case '=':
+						case '<':
+						case '>':
+						case '!':
+							sym[is].operator_priority = 1;
+							break;
+					}
+					sym[is].p = p;
+					sym[is].p_len = n;
+
+					cant_be_operator = 1;
+					goto loop_start;
+				}
+				else if (p[0] == ',')
+				{
+					n = 1;
+					bufprintf(comp_log, "Comma\n");
+					sym[is].type = sym_comma;
+					cant_be_operator = 1;
+					goto loop_start;
+				}
+			}
+			else if (p[0] == '-')
+			{
+				// Handle negation by inserting a 0 value symbol
+				sym[is].type = sym_value;
+				sym[is].p = "0";
+				sym[is].p_len = 1;
+
+				// Add '-' operator
+				is = sym_count;
+				alloc_enough(&sym, sym_count+=1, &sym_as, sizeof(symbol_data_t), 2.);
 				sym[is].type = sym_operator;
 				sym[is].p = p;
-				sym[is].p_len = n;
-
-				switch (p[0])
-				{
-					case '^':
-						sym[is].operator_priority = 4;
-						break;
-					case '*':
-					case '/':
-					case '%':
-						sym[is].operator_priority = 3;
-						break;
-					case '+':
-					case '-':
-						sym[is].operator_priority = 2;
-						break;
-					case '=':
-					case '<':
-					case '>':
-					case '!':
-						sym[is].operator_priority = 1;
-						break;
-				}
-
-				cant_be_operator = 1;
-				goto loop_start;
-			}
-			else if (p[0] == ',')
-			{
-				n = 1;
-				bufprintf(comp_log, "Comma\n");
-				sym[is].type = sym_comma;
+				sym[is].p_len = 1;
+				sym[is].depth = depth;
+				sym[is].operator_priority = 2;
 				cant_be_operator = 1;
 				goto loop_start;
 			}
@@ -151,7 +178,7 @@
 			sscanf(p, "%32[a-zA-Z0-9_]%n", name, &n);
 			if (n)
 			{
-				// The "pi" exception
+				// The "pi" exception TODO remove
 				if (pi_loaded == 0 && strcmp(name, "pi") == 0)
 				{
 					// Create a variable "pi" and call the pi function to set it
@@ -354,8 +381,8 @@
 			// Identify operator
 			int is_comparison = 0;
 			const char *identified_op=NULL, *identified_cmd=NULL;
-			const char *op[] =  {  "==",   "<",    ">",    "<=",   ">=",   "!=",   "+",   "-",   "*",   "/",  "%",  "^" };
-			const char *cmd[] = { "cmpr", "cmpr", "cmpr", "cmpr", "cmpr", "cmpr", "add", "sub", "mul", "div", "mod", "pow" };
+			const char *op[] =  {  "==",   "<",    ">",    "<=",   ">=",   "!=",   "+",   "-",   "*",   "/",  "%",   "^",   "^-" };
+			const char *cmd[] = { "cmpr", "cmpr", "cmpr", "cmpr", "cmpr", "cmpr", "add", "sub", "mul", "div", "mod", "pow", "pow" };
 			for (i=0; i < sizeof(op)/sizeof(*op); i++)
 				if (compare_varlen_word_to_fixlen_word(sym[is].p, sym[is].p_len, op[i]))
 				{
@@ -384,6 +411,30 @@

 			// Pick result ID
 			result_id = find_res_taken(is_comparison ? res_taken_i : res_taken_r, res_taken_count);
+
+			// Handle ^- exception (negative exponent) by inserting extra command
+			if (compare_varlen_word_to_fixlen_word(sym[is].p, sym[is].p_len, "^-"))
+			{
+				int result_id2 = find_res_taken(res_taken_r, res_taken_count);
+
+				// Print neg command
+				bufprintf(prog, "%c v%d = sub%s 0", var_decl, result_id2, cmd_suffix);
+
+				i = is+1;
+				// Print value or variable as it was written
+				if (sym[i].type == sym_value || sym[i].type == sym_variable)
+					bufprintf(prog, " %.*s\n", sym[i].p_len, sym[i].p);
+
+				// Print result variable
+				else if (sym[i].type == sym_result_real || sym[i].type == sym_result_int)
+					bufprintf(prog, " %c%d\n", sym[i].type == sym_result_real ? 'v' : 'i', sym[i].result_id);
+
+				// Replace input with result
+				sym[i].type = sym_result_real;
+				sym[i].result_id = result_id2;
+
+				res_taken_r[result_id2] = 0;
+			}

 			// Print start of command
 			if (is_comparison)
@@ -399,7 +450,7 @@
 					bufprintf(prog, " %.*s", sym[i].p_len, sym[i].p);

 				// Print result variables
-				if (sym[i].type == sym_result_real || sym[i].type == sym_result_int)
+				else if (sym[i].type == sym_result_real || sym[i].type == sym_result_int)
 					bufprintf(prog, " %c%d", sym[i].type == sym_result_real ? 'v' : 'i', sym[i].result_id);

 				// Print comparison operator


demux_shoutcast: fix object leak in case of error.

--- modules/demux/playlist/shoutcast.c
+++ modules/demux/playlist/shoutcast.c
@@ -75,9 +75,7 @@
     p_demux->p_sys->p_xml_reader = NULL;

     /* Do we want to list adult content ? */
-    var_Create( p_demux, "shoutcast-show-adult",
-                VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    p_demux->p_sys->b_adult = var_GetBool( p_demux, "shoutcast-show-adult" );
+    p_demux->p_sys->b_adult = var_CreateGetBool( p_demux, "shoutcast-show-adult" );

     return VLC_SUCCESS;
 }
@@ -107,17 +105,19 @@
     p_sys->p_current_input = p_current_input;

     p_xml = p_sys->p_xml = xml_Create( p_demux );
-    if( !p_xml ) return -1;
+    if( !p_xml )
+        goto error;

     p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
-    if( !p_xml_reader ) return -1;
+    if( !p_xml_reader )
+        goto error;
     p_sys->p_xml_reader = p_xml_reader;

     /* check root node */
     if( xml_ReaderRead( p_xml_reader ) != 1 )
     {
         msg_Err( p_demux, "invalid file (no root node)" );
-        return -1;
+        goto error;
     }

     if( xml_ReaderNodeType( p_xml_reader ) != XML_READER_STARTELEM ||
@@ -128,24 +128,30 @@
         msg_Err( p_demux, "invalid root node %i, %s",
                  xml_ReaderNodeType( p_xml_reader ), psz_eltname );
         free( psz_eltname );
-        return -1;
+        goto error;
     }

     if( !strcmp( psz_eltname, "genrelist" ) )
     {
         /* we're reading a genre list */
         free( psz_eltname );
-        if( DemuxGenre( p_demux ) ) return -1;
+        if( DemuxGenre( p_demux ) )
+            goto error;
     }
     else
     {
         /* we're reading a station list */
         free( psz_eltname );
-        if( DemuxStation( p_demux ) ) return -1;
+        if( DemuxStation( p_demux ) )
+            goto error;
     }

     HANDLE_PLAY_AND_RELEASE;
     return 0; /* Needed for correct operation of go back */
+
+error:
+    HANDLE_PLAY_AND_RELEASE;
+    return -1;
 }

 #define GET_VALUE( a ) \


Update settings.h

Update settings.h

--- rx5808-pro-diversityGc9n/settings.h
+++ rx5808-pro-diversityGc9n/settings.h
@@ -1,185 +1,189 @@
-/*
- * Setings file by Shea Ivey
-
-The MIT License (MIT)
-
-Copyright (c) 2015 Shea Ivey
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-#ifndef settings_h
-#define settings_h
-
-// Choose the display you will be using
-// you will also have to uncomment the includes in the main project.
-//#define TVOUT_SCREENS
-#define OLED_128x64_ADAFRUIT_SCREENS
-
-// use the library from https://github.com/badzz/Adafruit_SH1106 before enabling
-//#define SH1106
-
-// u8glib has performance issues.
-//#define OLED_128x64_U8G_SCREENS
-
-// this will be displayed on the screensaver.
-// Up to 10 letters
-#define CALL_SIGN "CALL SIGN"
-
-// Feature Togglels
-#define USE_DIVERSITY
-#define USE_IR_EMITTER
-//#define USE_FLIP_SCREEN
-#define USE_BOOT_LOGO
-// Choose if you wish to use 8 additional Channels
-// 5362 MHz 5399 MHz 5436 MHz 5473 MHz 5510 MHz 5547 MHz 5584 MHz 5621 MHz
-// Local laws may prohibit the use of these frequencies use at your own risk!
-#define USE_LBAND
-
-// Receiver Module version
-// used for tuning time
-#define rx5808
-//#define rx5880
-#define CH3 A3
-
-#define spiDataPin 10
-#define slaveSelectPin 11
-#define spiClockPin 12
-
-// Receiver PINS
-#define receiverA_led A0
-#define rssiPinA A6
-
-#define useReceiverA 1
-
-#ifdef USE_DIVERSITY
-    // Diversity
-    #define receiverB_led A1
-    #define rssiPinB A7
-    #define useReceiverAuto 0
-    #define useReceiverB 2
-    // rssi strenth should be 2% greater than other receiver before switch.
-    // this pervents flicker when rssi values are close and delays diversity checks counter.
-
-    #define DIVERSITY_CUTOVER 4 // changing this to 4% to try making it smoother
-
-    // Original comments number of checks a receiver needs to win over the other to switch receivers.
-    // this pervents rapid switching.
-
-    // 1 to 10 is a good range. 1 being fast switching, 10 being slow 100ms to switch.
-    #define DIVERSITY_MAX_CHECKS 7 //chaging this to 7 try making it smoother eliminate sync problems.
-#endif
-
-// this two are minimum required
-#define buttonUp 2
-#define buttonMode 3
-// optional comfort buttons
-#define buttonDown 4
-#define buttonSave 5
-// Buzzer
-#define buzzer 6
-
-// key debounce delay in ms
-// NOTE: good values are in the range of 100-200ms
-// shorter values will make it more reactive, but may lead to double trigger
-#define KEY_DEBOUNCE 200
-
-#define led 13
-// number of analog rssi reads to average for the current check.
-#define RSSI_READS 50
-// RSSI default raw range
-#define RSSI_MIN_VAL 90
-#define RSSI_MAX_VAL 220
-// 75% threshold, when channel is printed in spectrum
-#define RSSI_SEEK_FOUND 75
-// 80% under max value for RSSI
-#define RSSI_SEEK_TRESHOLD 80
-// scan loops for setup run
-#define RSSI_SETUP_RUN 3
-
-#define STATE_SEEK_FOUND 0
-#define STATE_SEEK 1
-#define STATE_SCAN 2
-#define STATE_MANUAL 3
-#ifdef USE_DIVERSITY
-    #define STATE_DIVERSITY 4
-#endif
-#define STATE_SETUP_MENU 5
-#define STATE_SAVE 6
-#define STATE_RSSI_SETUP 7
-#define STATE_SCREEN_SAVER 8
-#define STATE_FAVORITE 9 //gc9n
-
-// Seconds to wait before force entering screensaver
-#define SCREENSAVER_TIMEOUT 30
-
-#define START_STATE STATE_SEEK
-#define MAX_STATE STATE_MANUAL
-
-#define CHANNEL_BAND_SIZE 8
-#define CHANNEL_MIN_INDEX 0
-#ifdef USE_LBAND
-    #define CHANNEL_MAX_INDEX 47
-#else
-    #define CHANNEL_MAX_INDEX 39
-#endif
-
-#ifdef rx5808
-    // rx5808 module need >20ms to tune.
-    // 25 ms will do a 40 channel scan in 1 second.
-    #define MIN_TUNE_TIME 25
-#endif
-#ifdef rx5880
-    // rx5880 module needs >30ms to tune.
-    // 35 ms will do a 40 channel scan in 1.4 seconds.
-    #define MIN_TUNE_TIME 35
-#endif
-
-#ifdef USE_LBAND
-    #define CHANNEL_MAX 47
-#else
-    #define CHANNEL_MAX 39
-#endif
-#define CHANNEL_MIN 0
-
-#define EEPROM_ADR_STATE 0
-#define EEPROM_ADR_TUNE 1
-#define EEPROM_ADR_RSSI_MIN_A_L 2
-#define EEPROM_ADR_RSSI_MIN_A_H 3
-#define EEPROM_ADR_RSSI_MAX_A_L 4
-#define EEPROM_ADR_RSSI_MAX_A_H 5
-#ifdef USE_DIVERSITY
-
-    #define EEPROM_ADR_DIVERSITY 6
-    #define EEPROM_ADR_RSSI_MIN_B_L 7
-    #define EEPROM_ADR_RSSI_MIN_B_H 8
-    #define EEPROM_ADR_RSSI_MAX_B_L 9
-    #define EEPROM_ADR_RSSI_MAX_B_H 10
-
-    // used to figure out if diversity module has been plugged in.
-    // When RSSI is plugged in the min value is around 90
-    // When RSSI is not plugged in the min value is 0
-    #define isDiversity() (analogRead(rssiPinB) >= 5)
-#endif
-
-#define EEPROM_ADR_BEEP 11
-#define EEPROM_ADR_ORDERBY 12
-#define EEPROM_ADR_CALLSIGN 20
-
+/*
+ * Setings file by Shea Ivey
+
+The MIT License (MIT)
+
+Copyright (c) 2015 Shea Ivey
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+#include <avr/pgmspace.h>
+#ifndef settings_h
+#define settings_h
+
+
+#define Debug
+
+
+// Choose the display you will be using
+// you will also have to uncomment the includes in the main project.
+//#define TVOUT_SCREENS
+#define OLED_128x64_ADAFRUIT_SCREENS
+
+// use the library from https://github.com/badzz/Adafruit_SH1106 before enabling
+//#define SH1106
+
+// u8glib has performance issues.
+//#define OLED_128x64_U8G_SCREENS
+
+// this will be displayed on the screensaver.
+// Up to 10 letters
+#define CALL_SIGN "CALL SIGN"
+
+// Feature Togglels
+#define USE_DIVERSITY
+#define USE_IR_EMITTER
+//#define USE_FLIP_SCREEN
+#define USE_BOOT_LOGO
+// Choose if you wish to use 8 additional Channels
+// 5362 MHz 5399 MHz 5436 MHz 5473 MHz 5510 MHz 5547 MHz 5584 MHz 5621 MHz
+// Local laws may prohibit the use of these frequencies use at your own risk!
+#define USE_LBAND
+
+// Receiver Module version
+// used for tuning time
+#define rx5808
+//#define rx5880
+#define CH3 A3
+
+#define spiDataPin 10
+#define slaveSelectPin 11
+#define spiClockPin 12
+
+// Receiver PINS
+#define receiverA_led A0
+#define rssiPinA A6
+
+#define useReceiverA 1
+
+#ifdef USE_DIVERSITY
+    // Diversity
+    #define receiverB_led A1
+    #define rssiPinB A7
+    #define useReceiverAuto 0
+    #define useReceiverB 2
+    // rssi strenth should be 2% greater than other receiver before switch.
+    // this pervents flicker when rssi values are close and delays diversity checks counter.
+
+    #define DIVERSITY_CUTOVER 4 // changing this to 4% to try making it smoother
+
+    // Original comments number of checks a receiver needs to win over the other to switch receivers.
+    // this pervents rapid switching.
+
+    // 1 to 10 is a good range. 1 being fast switching, 10 being slow 100ms to switch.
+    #define DIVERSITY_MAX_CHECKS 7 //chaging this to 7 try making it smoother eliminate sync problems.
+#endif
+
+// this two are minimum required
+#define buttonUp 2
+#define buttonMode 3
+// optional comfort buttons
+#define buttonDown 4
+#define buttonSave 5
+// Buzzer
+#define buzzer 6
+
+// key debounce delay in ms
+// NOTE: good values are in the range of 100-200ms
+// shorter values will make it more reactive, but may lead to double trigger
+#define KEY_DEBOUNCE 200
+
+#define led 13
+// number of analog rssi reads to average for the current check.
+#define RSSI_READS 50
+// RSSI default raw range
+#define RSSI_MIN_VAL 90
+#define RSSI_MAX_VAL 220
+// 75% threshold, when channel is printed in spectrum
+#define RSSI_SEEK_FOUND 75
+// 80% under max value for RSSI
+#define RSSI_SEEK_TRESHOLD 80
+// scan loops for setup run
+#define RSSI_SETUP_RUN 3
+
+#define STATE_SEEK_FOUND 0
+#define STATE_SEEK 1
+#define STATE_SCAN 2
+#define STATE_MANUAL 3
+#ifdef USE_DIVERSITY
+    #define STATE_DIVERSITY 4
+#endif
+#define STATE_SETUP_MENU 5
+#define STATE_SAVE 6
+#define STATE_RSSI_SETUP 7
+#define STATE_SCREEN_SAVER 8
+#define STATE_FAVORITE 9 //gc9n
+
+// Seconds to wait before force entering screensaver
+#define SCREENSAVER_TIMEOUT 10
+
+#define START_STATE STATE_SEEK
+#define MAX_STATE STATE_MANUAL
+
+#define CHANNEL_BAND_SIZE 8
+#define CHANNEL_MIN_INDEX 0
+#ifdef USE_LBAND
+    #define CHANNEL_MAX_INDEX 47
+#else
+    #define CHANNEL_MAX_INDEX 39
+#endif
+
+#ifdef rx5808
+    // rx5808 module need >20ms to tune.
+    // 25 ms will do a 40 channel scan in 1 second.
+    #define MIN_TUNE_TIME 25
+#endif
+#ifdef rx5880
+    // rx5880 module needs >30ms to tune.
+    // 35 ms will do a 40 channel scan in 1.4 seconds.
+    #define MIN_TUNE_TIME 35
+#endif
+
+#ifdef USE_LBAND
+    #define CHANNEL_MAX 47
+#else
+    #define CHANNEL_MAX 39
+#endif
+#define CHANNEL_MIN 0
+
+#define EEPROM_ADR_STATE 0
+#define EEPROM_ADR_TUNE 1
+#define EEPROM_ADR_RSSI_MIN_A_L 2
+#define EEPROM_ADR_RSSI_MIN_A_H 3
+#define EEPROM_ADR_RSSI_MAX_A_L 4
+#define EEPROM_ADR_RSSI_MAX_A_H 5
+#ifdef USE_DIVERSITY
+
+    #define EEPROM_ADR_DIVERSITY 6
+    #define EEPROM_ADR_RSSI_MIN_B_L 7
+    #define EEPROM_ADR_RSSI_MIN_B_H 8
+    #define EEPROM_ADR_RSSI_MAX_B_L 9
+    #define EEPROM_ADR_RSSI_MAX_B_H 10
+
+    // used to figure out if diversity module has been plugged in.
+    // When RSSI is plugged in the min value is around 90
+    // When RSSI is not plugged in the min value is 0
+    #define isDiversity() (analogRead(rssiPinB) >= 5)
+#endif
+
+#define EEPROM_ADR_BEEP 11
+#define EEPROM_ADR_ORDERBY 12
+#define EEPROM_ADR_CALLSIGN 20
+
 #endif // file_defined


powerpc/ftrace: Trace function graph entry before updating index

As Colin Cross ported my x86 change to ARM, he also pointed out that
powerpc is also behind in this fix.

The commit 722b3c746953 "ftrace/graph: Trace function entry before
updating index" fixes an issue with function graph tracing for x86,
where if the called entry function decides not to trace interrupts, it
can fail the check if an interrupt comes in just after the
curr_ret_stack is updated.

The solution is to call the entry function first, then update the
curr_ret_stack if the entry function wants to be traced.

Cc: Colin Cross <380081620a7947c89c11153c5513f34019caa923@android.com>
Signed-off-by: Steven Rostedt <43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>

--- arch/powerpc/kernel/ftrace.c
+++ arch/powerpc/kernel/ftrace.c
@@ -630,18 +630,17 @@
 		return;
 	}

-	if (ftrace_push_return_trace(old, self_addr, &trace.depth, 0) == -EBUSY) {
+	trace.func = self_addr;
+	trace.depth = current->curr_ret_stack + 1;
+
+	/* Only trace if the calling function expects to */
+	if (!ftrace_graph_entry(&trace)) {
 		*parent = old;
 		return;
 	}

-	trace.func = self_addr;
-
-	/* Only trace if the calling function expects to */
-	if (!ftrace_graph_entry(&trace)) {
-		current->curr_ret_stack--;
+	if (ftrace_push_return_trace(old, self_addr, &trace.depth, 0) == -EBUSY)
 		*parent = old;
-	}
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */


[POWERPC] Fix debug printks for 32-bit resources in the PCI code

Cure the damage done by the former PCI debug printks fix for the case
of 64-bit resources (commit 685143ac1f7a579a3fac9c7f2ac8f82e95af6864)
which broke it for the plain vanilla 32-bit resources...

Signed-off-by: Sergei Shtylyov <38a867ea26f35d3eeb42270f1bc7b9d1d135e6a2@ru.mvista.com>
Signed-off-by: Paul Mackerras <19a0ba370c443ba08d20b5061586430ab449ee8c@samba.org>

--- arch/powerpc/kernel/pci_32.c
+++ arch/powerpc/kernel/pci_32.c
@@ -100,7 +100,7 @@
 			continue;
 		if (res->end == 0xffffffff) {
 			DBG("PCI:%s Resource %d [%016llx-%016llx] is unassigned\n",
-			    pci_name(dev), i, res->start, res->end);
+			    pci_name(dev), i, (u64)res->start, (u64)res->end);
 			res->end -= res->start;
 			res->start = 0;
 			res->flags |= IORESOURCE_UNSET;
@@ -116,11 +116,9 @@
 		if (offset != 0) {
 			res->start += offset;
 			res->end += offset;
-#ifdef DEBUG
-			printk("Fixup res %d (%lx) of dev %s: %llx -> %llx\n",
-			       i, res->flags, pci_name(dev),
-			       res->start - offset, res->start);
-#endif
+			DBG("Fixup res %d (%lx) of dev %s: %llx -> %llx\n",
+			    i, res->flags, pci_name(dev),
+			    (u64)res->start - offset, (u64)res->start);
 		}
 	}

@@ -256,7 +254,7 @@
 			}

 			DBG("PCI: bridge rsrc %llx..%llx (%lx), parent %p\n",
-				res->start, res->end, res->flags, pr);
+			    (u64)res->start, (u64)res->end, res->flags, pr);
 			if (pr) {
 				if (request_resource(pr, res) == 0)
 					continue;
@@ -307,7 +305,7 @@
 	for (p = res->child; p != NULL; p = p->sibling) {
 		p->parent = res;
 		DBG(KERN_INFO "PCI: reparented %s [%llx..%llx] under %s\n",
-		    p->name, p->start, p->end, res->name);
+		    p->name, (u64)p->start, (u64)p->end, res->name);
 	}
 	return 0;
 }
@@ -363,7 +361,7 @@
 	}
 	if (request_resource(pr, res)) {
 		DBG(KERN_ERR "PCI: huh? couldn't move to %llx..%llx\n",
-		    res->start, res->end);
+		    (u64)res->start, (u64)res->end);
 		return -1;		/* "can't happen" */
 	}
 	update_bridge_base(bus, i);
@@ -481,14 +479,14 @@
 	struct resource *pr, *r = &dev->resource[idx];

 	DBG("PCI:%s: Resource %d: %016llx-%016llx (f=%lx)\n",
-	    pci_name(dev), idx, r->start, r->end, r->flags);
+	    pci_name(dev), idx, (u64)r->start, (u64)r->end, r->flags);
 	pr = pci_find_parent_resource(dev, r);
 	if (!pr || request_resource(pr, r) < 0) {
 		printk(KERN_ERR "PCI: Cannot allocate resource region %d"
 		       " of device %s\n", idx, pci_name(dev));
 		if (pr)
 			DBG("PCI:  parent is %p: %016llx-%016llx (f=%lx)\n",
-			    pr, pr->start, pr->end, pr->flags);
+			    pr, (u64)pr->start, (u64)pr->end, pr->flags);
 		/* We'll assign a new address later */
 		r->flags |= IORESOURCE_UNSET;
 		r->end -= r->start;
@@ -961,7 +959,7 @@
 			res->flags = IORESOURCE_IO;
 			res->start = ranges[2];
 			DBG("PCI: IO 0x%llx -> 0x%llx\n",
-				    res->start, res->start + size - 1);
+			    (u64)res->start, (u64)res->start + size - 1);
 			break;
 		case 2:		/* memory space */
 			memno = 0;
@@ -983,7 +981,7 @@
 					res->flags |= IORESOURCE_PREFETCH;
 				res->start = ranges[na+2];
 				DBG("PCI: MEM[%d] 0x%llx -> 0x%llx\n", memno,
-					    res->start, res->start + size - 1);
+				    (u64)res->start, (u64)res->start + size - 1);
 			}
 			break;
 		}


post_receive still needs to timeout if it can't find any free bufferes.

--- lib/maca.c
+++ lib/maca.c
@@ -122,6 +122,11 @@
 		dma_rx = get_free_packet();
 		if (dma_rx == 0) {
 			printf("trying to fill MACA_DMARX but out of packet buffers\n\r");
+			/* set the sftclock so that we return to the maca_isr */
+			*MACA_SFTCLK = *MACA_CLK + RECV_SOFTIMEOUT; /* soft timeout */
+			*MACA_TMREN = (1 << maca_tmren_sft);
+			/* no free buffers, so don't start a reception */
+			enable_irq(MACA);
 			return;
 		}
 	}


KVM: PPC: BOOK3S: PR: Fix WARN_ON with debug options on

With debug option "sleep inside atomic section checking" enabled we get
the below WARN_ON during a PR KVM boot. This is because upstream now
have PREEMPT_COUNT enabled even if we have preempt disabled. Fix the
warning by adding preempt_disable/enable around floating point and altivec
enable.

WARNING: at arch/powerpc/kernel/process.c:156
Modules linked in: kvm_pr kvm
CPU: 1 PID: 3990 Comm: qemu-system-ppc Tainted: G        W     3.15.0-rc1+ #4
task: c0000000eb85b3a0 ti: c0000000ec59c000 task.ti: c0000000ec59c000
NIP: c000000000015c84 LR: d000000003334644 CTR: c000000000015c00
REGS: c0000000ec59f140 TRAP: 0700   Tainted: G        W      (3.15.0-rc1+)
MSR: 8000000000029032 <SF,EE,ME,IR,DR,RI>  CR: 42000024  XER: 20000000
CFAR: c000000000015c24 SOFTE: 1
GPR00: d000000003334644 c0000000ec59f3c0 c000000000e2fa40 c0000000e2f80000
GPR04: 0000000000000800 0000000000002000 0000000000000001 8000000000000000
GPR08: 0000000000000001 0000000000000001 0000000000002000 c000000000015c00
GPR12: d00000000333da18 c00000000fb80900 0000000000000000 0000000000000000
GPR16: 0000000000000000 0000000000000000 0000000000000000 00003fffce4e0fa1
GPR20: 0000000000000010 0000000000000001 0000000000000002 00000000100b9a38
GPR24: 0000000000000002 0000000000000000 0000000000000000 0000000000000013
GPR28: 0000000000000000 c0000000eb85b3a0 0000000000002000 c0000000e2f80000
NIP [c000000000015c84] .enable_kernel_fp+0x84/0x90
LR [d000000003334644] .kvmppc_handle_ext+0x134/0x190 [kvm_pr]
Call Trace:
[c0000000ec59f3c0] [0000000000000010] 0x10 (unreliable)
[c0000000ec59f430] [d000000003334644] .kvmppc_handle_ext+0x134/0x190 [kvm_pr]
[c0000000ec59f4c0] [d00000000324b380] .kvmppc_set_msr+0x30/0x50 [kvm]
[c0000000ec59f530] [d000000003337cac] .kvmppc_core_emulate_op_pr+0x16c/0x5e0 [kvm_pr]
[c0000000ec59f5f0] [d00000000324a944] .kvmppc_emulate_instruction+0x284/0xa80 [kvm]
[c0000000ec59f6c0] [d000000003336888] .kvmppc_handle_exit_pr+0x488/0xb70 [kvm_pr]
[c0000000ec59f790] [d000000003338d34] kvm_start_lightweight+0xcc/0xdc [kvm_pr]
[c0000000ec59f960] [d000000003336288] .kvmppc_vcpu_run_pr+0xc8/0x190 [kvm_pr]
[c0000000ec59f9f0] [d00000000324c880] .kvmppc_vcpu_run+0x30/0x50 [kvm]
[c0000000ec59fa60] [d000000003249e74] .kvm_arch_vcpu_ioctl_run+0x54/0x1b0 [kvm]
[c0000000ec59faf0] [d000000003244948] .kvm_vcpu_ioctl+0x478/0x760 [kvm]
[c0000000ec59fcb0] [c000000000224e34] .do_vfs_ioctl+0x4d4/0x790
[c0000000ec59fd90] [c000000000225148] .SyS_ioctl+0x58/0xb0
[c0000000ec59fe30] [c00000000000a1e4] syscall_exit+0x0/0x98

Signed-off-by: Aneesh Kumar K.V <f511f818e8a0748edef6b9ee378967da9ed0c78f@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <3ad82b0c937b9aa51276120cedd545efc822be04@suse.de>

--- arch/powerpc/kvm/book3s_pr.c
+++ arch/powerpc/kvm/book3s_pr.c
@@ -683,16 +683,20 @@
 #endif

 	if (msr & MSR_FP) {
+		preempt_disable();
 		enable_kernel_fp();
 		load_fp_state(&vcpu->arch.fp);
 		t->fp_save_area = &vcpu->arch.fp;
+		preempt_enable();
 	}

 	if (msr & MSR_VEC) {
 #ifdef CONFIG_ALTIVEC
+		preempt_disable();
 		enable_kernel_altivec();
 		load_vr_state(&vcpu->arch.vr);
 		t->vr_save_area = &vcpu->arch.vr;
+		preempt_enable();
 #endif
 	}

@@ -716,13 +720,17 @@
 		return;

 	if (lost_ext & MSR_FP) {
+		preempt_disable();
 		enable_kernel_fp();
 		load_fp_state(&vcpu->arch.fp);
+		preempt_enable();
 	}
 #ifdef CONFIG_ALTIVEC
 	if (lost_ext & MSR_VEC) {
+		preempt_disable();
 		enable_kernel_altivec();
 		load_vr_state(&vcpu->arch.vr);
+		preempt_enable();
 	}
 #endif
 	current->thread.regs->msr |= lost_ext;


docs: fix simple typo, subsetquent -> subsequent

There is a small typo in yajl-2.1.0/yajl_lex.h.

Should read `subsequent` rather than `subsetquent`.

--- yajl-2.1.0/yajl_lex.h
+++ yajl-2.1.0/yajl_lex.h
@@ -56,7 +56,7 @@
 /**
  * run/continue a lex. "offset" is an input/output parameter.
  * It should be initialized to zero for a
- * new chunk of target text, and upon subsetquent calls with the same
+ * new chunk of target text, and upon subsequent calls with the same
  * target text should passed with the value of the previous invocation.
  *
  * the client may be interested in the value of offset when an error is


added TODO markers for OOM cases

added TODO markers for OOM cases

--- arangod/VocBase/simple-collection.c
+++ arangod/VocBase/simple-collection.c
@@ -330,6 +330,7 @@

   // get a new header pointer
   header = sim->_headers->request(sim->_headers);
+  // TODO: header might be NULL and must be checked

   if (did > 0 && rid > 0) {
     // use existing document id & revision id
@@ -1339,6 +1340,7 @@
       TRI_doc_mptr_t* header;

       header = collection->_headers->request(collection->_headers);
+      // TODO: header might be NULL and must be checked
       header = collection->_headers->verify(collection->_headers, header);

       // fill the header
@@ -1420,6 +1422,7 @@
       TRI_doc_mptr_t* header;

       header = collection->_headers->request(collection->_headers);
+      // TODO: header might be NULL and must be checked
       header = collection->_headers->verify(collection->_headers, header);

       header->_did = d->_did;


powerpc/book3e: Clarify HW table walk enable/disable message

Before if we didn't support or enable HW table walk we'd get a messaage
like:

MMU: Book3E Page Tables Disabled

Which is a bit misleading.  Now it will say:

MMU: Book3E HW tablewalk not supported

Signed-off-by: Kumar Gala <383ef5577c6e1178b93f59ec8d0936f76d2a98c4@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>

--- arch/powerpc/mm/tlb_nohash.c
+++ arch/powerpc/mm/tlb_nohash.c
@@ -473,8 +473,8 @@
 			     (unsigned long)&exc_instruction_tlb_miss_htw_book3e, 0);
 		book3e_htw_enabled = 1;
 	}
-	pr_info("MMU: Book3E Page Tables %s\n",
-		book3e_htw_enabled ? "Enabled" : "Disabled");
+	pr_info("MMU: Book3E HW tablewalk %s\n",
+		book3e_htw_enabled ? "enabled" : "not supported");
 }

 /*


[numerics] correct tests after merge

[numerics] correct tests after merge

--- numerics/src/tools/test/NumericsMatrix_add_to_diag3.c
+++ numerics/src/tools/test/NumericsMatrix_add_to_diag3.c
@@ -88,9 +88,8 @@

   printf("========= Starts Numerics tests for NM_add_to_diag3 ========= \n");

-  SparseBlockStructuredMatrix * SBM = SBM_new();
   FILE *file = fopen("data/SBM1.dat", "r");
-  SBM_new_from_file(SBM, file);
+  SparseBlockStructuredMatrix * SBM = SBM_new_from_file(file);
   fclose(file);

   NumericsMatrix * M = NM_create(NM_SPARSE_BLOCK, SBM->blocksize0[SBM->blocknumber0-1],SBM->blocksize1[SBM->blocknumber1-1] );


remove debugging

remove debugging

--- Eigen/src/Core/arch/ZVector/Complex.h
+++ Eigen/src/Core/arch/ZVector/Complex.h
@@ -428,28 +428,20 @@
 {
   Packet4f a_re, a_im, prod, prod_im;

-  std::cout << "a = " << a.v << std::endl;
-  std::cout << ", b = " << b.v << std::endl;
   // Permute and multiply the real parts of a and b
   a_re = vec_perm(a.v, a.v, p16uc_PSET32_WODD);

-  std::cout << "a_re = " << a_re << std::endl;
   // Get the imaginary parts of a
   a_im = vec_perm(a.v, a.v, p16uc_PSET32_WEVEN);
-  std::cout << "a_im = " << a_im << std::endl;

   // multiply a_im * b and get the conjugate result
   prod_im = a_im * b.v;
-  std::cout << "prod_im = " << prod_im << std::endl;
   prod_im = pxor<Packet4f>(prod_im, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR));
-  std::cout << "prod_im = " << prod_im << std::endl;
   // permute back to a proper order
   prod_im = vec_perm(prod_im, prod_im, p16uc_COMPLEX32_REV);
-  std::cout << "prod_im = " << prod_im << std::endl;

   // multiply a_re * b, add prod_im
   prod = pmadd<Packet4f>(a_re, b.v, prod_im);
-  std::cout << "prod = " << prod << std::endl;

   return Packet2cf(prod);
 }


ARM: imx5: use dynamic mapping for CCM block

Replace the static mapping of CCM block with dynamic mapping and
retrieve CCM base address from device tree.  Though it's not nice to
encode the variable ccm_base in macros, it helps to avoid a massive
churn on the code.

Signed-off-by: Shawn Guo <912cf7eb7d8018e2943586ae6657d21fd4e38239@freescale.com>


s390/bpf,jit: address randomize and write protect jit code

This is the s390 variant of 314beb9b "x86: bpf_jit_comp: secure bpf
jit against spraying attacks".
With this change the whole jit code and literal pool will be write
protected after creation. In addition the start address of the jit
code won't be always on a page boundary anymore.

Signed-off-by: Heiko Carstens <8dcf0f69152f32f23184f83357a3731522e56b9c@de.ibm.com>
Signed-off-by: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>

--- arch/s390/net/bpf_jit_comp.c
+++ arch/s390/net/bpf_jit_comp.c
@@ -9,6 +9,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_vlan.h>
 #include <linux/filter.h>
+#include <linux/random.h>
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
 #include <asm/facility.h>
@@ -738,8 +739,41 @@
 	return -1;
 }

+/*
+ * Note: for security reasons, bpf code will follow a randomly
+ *	 sized amount of illegal instructions.
+ */
+struct bpf_binary_header {
+	unsigned int pages;
+	u8 image[];
+};
+
+static struct bpf_binary_header *bpf_alloc_binary(unsigned int bpfsize,
+						  u8 **image_ptr)
+{
+	struct bpf_binary_header *header;
+	unsigned int sz, hole;
+
+	/* Most BPF filters are really small, but if some of them fill a page,
+	 * allow at least 128 extra bytes for illegal instructions.
+	 */
+	sz = round_up(bpfsize + sizeof(*header) + 128, PAGE_SIZE);
+	header = module_alloc(sz);
+	if (!header)
+		return NULL;
+	memset(header, 0, sz);
+	header->pages = sz / PAGE_SIZE;
+	hole = sz - bpfsize + sizeof(*header);
+	/* Insert random number of illegal instructions before BPF code
+	 * and make sure the first instruction starts at an even address.
+	 */
+	*image_ptr = &header->image[(prandom_u32() % hole) & -2];
+	return header;
+}
+
 void bpf_jit_compile(struct sk_filter *fp)
 {
+	struct bpf_binary_header *header = NULL;
 	unsigned long size, prg_len, lit_len;
 	struct bpf_jit jit, cjit;
 	unsigned int *addrs;
@@ -775,8 +809,8 @@
 			size = prg_len + lit_len;
 			if (size >= BPF_SIZE_MAX)
 				goto out;
-			jit.start = module_alloc(size);
-			if (!jit.start)
+			header = bpf_alloc_binary(size, &jit.start);
+			if (!header)
 				goto out;
 			jit.prg = jit.mid = jit.start + prg_len;
 			jit.lit = jit.end = jit.start + prg_len + lit_len;
@@ -791,14 +825,21 @@
 		if (jit.start)
 			print_fn_code(jit.start, jit.mid - jit.start);
 	}
-	if (jit.start)
+	if (jit.start) {
+		set_memory_ro((unsigned long)header, header->pages);
 		fp->bpf_func = (void *) jit.start;
+	}
 out:
 	kfree(addrs);
 }

 void bpf_jit_free(struct sk_filter *fp)
 {
-	if (fp->bpf_func != sk_run_filter)
-		module_free(NULL, fp->bpf_func);
+	unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
+	struct bpf_binary_header *header = (void *)addr;
+
+	if (fp->bpf_func == sk_run_filter)
+		return;
+	set_memory_rw(addr, header->pages);
+	module_free(NULL, header);
 }


msm: acpuclock-krait: Only print supported number of frequencies once

The current code prints the number of CPU frequencies supported
once for each possible CPU, even though the number of supported
frequencies is the same for each CPU. Cut down on log noise by
printing this number only once.

For example, print:

  [ 0.412932] acpuclk-8974 qcom,acpuclk.23: CPU Frequencies Supported: 11

...instead of:

  [ 0.426013] acpuclk-8974 qcom,acpuclk.23: CPU0: 11 frequencies supported
  [ 0.426052] acpuclk-8974 qcom,acpuclk.23: CPU1: 11 frequencies supported
  [ 0.426089] acpuclk-8974 qcom,acpuclk.23: CPU2: 11 frequencies supported
  [ 0.426124] acpuclk-8974 qcom,acpuclk.23: CPU3: 11 frequencies supported

Change-Id: Iaf15970e6cfcfaec79c0edf8564cab9141fbc05f
Signed-off-by: Matt Wagantall <f353a1326f7aad71d23381a3beb9470c3b31d81b@codeaurora.org>

--- arch/arm/mach-msm/acpuclock-krait.c
+++ arch/arm/mach-msm/acpuclock-krait.c
@@ -923,11 +923,12 @@
 static void __init cpufreq_table_init(void)
 {
 	int cpu;
+	int freq_cnt = 0;

 	for_each_possible_cpu(cpu) {
-		int i, freq_cnt = 0;
+		int i;
 		/* Construct the freq_table tables from acpu_freq_tbl. */
-		for (i = 0; drv.acpu_freq_tbl[i].speed.khz != 0
+		for (i = 0, freq_cnt = 0; drv.acpu_freq_tbl[i].speed.khz != 0
 				&& freq_cnt < ARRAY_SIZE(*freq_table); i++) {
 			if (drv.acpu_freq_tbl[i].use_for_scaling) {
 				freq_table[cpu][freq_cnt].index = freq_cnt;
@@ -942,12 +943,11 @@
 		freq_table[cpu][freq_cnt].index = freq_cnt;
 		freq_table[cpu][freq_cnt].frequency = CPUFREQ_TABLE_END;

-		dev_info(drv.dev, "CPU%d: %d frequencies supported\n",
-			cpu, freq_cnt);
-
 		/* Register table with CPUFreq. */
 		cpufreq_frequency_table_get_attr(freq_table[cpu], cpu);
 	}
+
+	dev_info(drv.dev, "CPU Frequencies Supported: %d\n", freq_cnt);
 }
 #else
 static void __init cpufreq_table_init(void) {}


ARM: S3C24XX: dma-s3c2443 - do not write into arbitary bits

The values read from the channel map always also contain the
DMA_CH_VALID (= 1<<31) setting, which should not get written
into the register, even if this bit is unused.

Signed-off-by: Heiko Stuebner <9ab5f52a1ca0bcf4f70d6d9008e02f6134b5b8f2@sntech.de>
Signed-off-by: Kukjin Kim <3fc711f4e08bc570a586748633ff7c76d0e1e253@samsung.com>


[hm] Baud rate now 38400

[hm] Baud rate now 38400

--- arduino/heatermeter/hmcore.h
+++ arduino/heatermeter/hmcore.h
@@ -3,7 +3,7 @@
 #define __HMCORE_H__

 //#define HEATERMETER_NETWORKING  // enable wifi interface
-#define HEATERMETER_SERIAL 115200 // enable serial interface
+#define HEATERMETER_SERIAL 38400 // enable serial interface
 #define HEATERMETER_RFM12  RF12_915MHZ  // enable RFM12B receiving (433MHZ|868MHZ|915MHZ)
 //#define USE_EXTERNAL_VREF       // Using external 5V as reference to analog inputs
 #define PIEZO_HZ 4000             // enable piezo buzzer at this frequency


CRISv32: annotate irq enable in idle loop

Use a call to local_irq_enable() instead of incline asm so that the
irqsoff latency tracer knows that interrupts are enabled here.

Signed-off-by: Rabin Vincent <6bd3f43fd5b2b5689bccc97f6d09e3eb28307598@rab.in>
Signed-off-by: Jesper Nilsson <987a7dbc972893e93e5578401bedc3a0f2ccb5e3@axis.com>