isDipesh / gnome-shell-extension-sensors

Gnome shell extension: Shows CPU temperature, HDD temperature, voltage and fan RPM
https://motorscript.com/gnome-shell-extension-sensors/
161 stars 153 forks source link

the extension produces warnings #70

Closed turl closed 11 years ago

turl commented 11 years ago

Hi, I was getting the following two warnings on my log file on GNOME 3.8

JS ERROR: !!!   WARNING: file '/home/user/.local/share/gnome-shell/extensions/temperature@xtranophilist/utilities.js' line 151 exception 0
JS ERROR: !!!   WARNING: 'assignment to undeclared variable line'
JS ERROR: !!!   WARNING: file '/home/user/.local/share/gnome-shell/extensions/temperature@xtranophilist/utilities.js' line 53 exception 0 
JS ERROR: !!!   WARNING: 'assignment to undeclared variable r'

I did the following changes to the code and it seems to be working ok and without the warnings

--- a/utilities.js
+++ b/utilities.js
@@ -50,7 +50,8 @@ function detectHDDTemp() {
         // get daemon command line
         let cmdline = GLib.file_get_contents('/proc/'+pid+'/cmdline');
         // get port or assume default
-        let port = (r=/(-p\W*|--port=)(\d{1,5})/.exec(cmdline)) ? parseInt(r[2]) : 7634;
+        let r = /(-p\W*|--port=)(\d{1,5})/.exec(cmdline)
+        let port = r ? parseInt(r[2]) : 7634;
         // use net cat to get data
         return [nc, 'localhost', port.toString()];
     }
@@ -148,7 +149,7 @@ function parseVoltageLine(label, value) {
 function parseHddTempOutput(txt, sep) {
     let hddtemp_output = txt.split("\n").filter(function(e){ return e; });
     let sensors = new Array();
-    for each(line in hddtemp_output)
+    for each(let line in hddtemp_output)
     {
         let sensor = new Array();
         let fields = line.split(sep).filter(function(e){ return e; });
adrianbroher commented 11 years ago

Thanks for your report.